Skip to content

Make unit tests for oneCore pass under the versions of Windows where oneCore is not supported#12702

Merged
seanbudd merged 2 commits into
nvaccess:masterfrom
lukaszgo1:dontTestOneCoreWhereUnsupported
Aug 2, 2021
Merged

Make unit tests for oneCore pass under the versions of Windows where oneCore is not supported#12702
seanbudd merged 2 commits into
nvaccess:masterfrom
lukaszgo1:dontTestOneCoreWhereUnsupported

Conversation

@lukaszgo1

@lukaszgo1 lukaszgo1 commented Jul 30, 2021

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes unit tests introduced in #12647

Summary of the issue:

Some unit tests introduced as part of #12647 were failing under versions of Windows where oneCore was unsupported. The output was as follows:

FAIL: Ensures that if oneCore doesn't support the current language, setSynth("auto") falls back to the
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\my_repos\nvda\tests\unit\test_synthDriverHandler.py", line 113, in test_setSynth_auto_fallback_ifOneCoreDoesntSupportDefaultLangauge
    self.assertEqual(synthDriverHandler.getSynth().name, FAKE_DEFAULT_SYNTH_NAME)
AssertionError: 'espeak' != 'defaultSynth'
- espeak
+ defaultSynth


======================================================================
FAIL: Ensures that if oneCore supports the current language, setSynth("auto") uses "oneCore".
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\my_repos\nvda\tests\unit\test_synthDriverHandler.py", line 104, in test_setSynth_auto_usesOneCore_ifSupportsDefaultLangauge
    self.assertEqual(synthDriverHandler.getSynth().name, "oneCore")
AssertionError: 'espeak' != 'oneCore'
- espeak
+ oneCore

Description of how this pull request fixes the issue:

Tests which require oneCore being supported are being skipped on versions of Windows on which oneCore is not supported.

Testing strategy:

Unit tests passes locally whereas previously they didn't. I'll inspect log on AppVeyor to ensure they still pass on a version of Windows where oneCore is supported.

Known issues with pull request:

None known.

Change log entries:

None needed

Code Review Checklist:

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual testing.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers

@lukaszgo1 lukaszgo1 marked this pull request as ready for review July 30, 2021 16:52
@lukaszgo1 lukaszgo1 requested a review from a team as a code owner July 30, 2021 16:52
@lukaszgo1 lukaszgo1 requested a review from seanbudd July 30, 2021 16:52
@Brian1Gaff

Brian1Gaff commented Jul 31, 2021 via email

Copy link
Copy Markdown

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

Are not the u and a in Language the wrong way around in the code?

This has been fixed as part of this PR.

@seanbudd

seanbudd commented Aug 2, 2021

Copy link
Copy Markdown
Member

I think performing logic within the test defeats the purpose of these tests. Generally you should avoid conditional logic within unit testing. I think it might be better to just add these wrappers to the existing oneCore tests

@unittest.case.skipIf(winVersion.getWinVer() < winVersion.WIN10, "oneCore unsupported on this OS")

@lukaszgo1 lukaszgo1 force-pushed the dontTestOneCoreWhereUnsupported branch from 159b3b9 to de9cd87 Compare August 2, 2021 10:40
@lukaszgo1

Copy link
Copy Markdown
Contributor Author

I think performing logic within the test defeats the purpose of these tests. Generally you should avoid conditional logic within unit testing.

I agree conditional logic is an anti-pattern for unit tests however currently these test rely on defaultSynthPriorityList being set in a particular way which differs between the version of Windows in use which is also an anti-pattern IMO.

I think it might be better to just add these wrappers to the existing oneCore tests

I've done mostly as you suggested however rather than testing for a version of Windows in use I'm checking for oneCore being supported which guarantees that if we would need to ever drop support of it and / or it would become broken on a particular version of Windows the check would not need to be modifiied in more than one place.

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lukaszgo1, looks good to me.

@seanbudd seanbudd merged commit 62ad576 into nvaccess:master Aug 2, 2021
@nvaccessAuto nvaccessAuto added this to the 2021.3 milestone Aug 2, 2021
@lukaszgo1 lukaszgo1 deleted the dontTestOneCoreWhereUnsupported branch August 3, 2021 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants