-
-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly report accented letters after cap #11977
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be really helpful if this added unit tests for these modified functions.
OK, I will have a look at it. Passing this PR as draft while developing unit tests. |
It's probably clearer to test the three internal functions separately. |
Hello @feerrenrut I am trying to set up unit test for the new functions. I am not used to unit test development and have not ever done it for NVDA. Thus, I need some guidance. I have created a def test_symbolNameAtTheEnd(self):
seq = makeGen(['h', EndUtteranceCommand(), 'e', EndUtteranceCommand(), 'l', EndUtteranceCommand(), 'l', EndUtteranceCommand(), 'o', EndUtteranceCommand(), 'bang', EndUtteranceCommand()])
expected = repr([CharacterModeCommand(True), 'h', EndUtteranceCommand(), 'e', EndUtteranceCommand(), 'l', EndUtteranceCommand(), 'l', EndUtteranceCommand(), 'o', EndUtteranceCommand(), CharacterModeCommand(False), 'bang', EndUtteranceCommand()])
output = _getSpellingSpeechAddCharMode(seq)
self.assertEqual(repr(list(output)), expected) When running the unit test, I get the following error:
There is probably some sort of stub in unit tests that allow to avoid having a real synth driver. Also, any feedback is welcome. All this is quite new for me. Thanks for your help. |
Ok, I see the issue, several of these newly introduced methods are coupled to The test would become like: def test_symbolNameAtTheEnd(self):
seq = makeGen([
'h', EndUtteranceCommand(),
'e', EndUtteranceCommand(),
'l', EndUtteranceCommand(),
'l', EndUtteranceCommand(),
'o', EndUtteranceCommand(),
'bang', EndUtteranceCommand()
])
expected = repr([
CharacterModeCommand(True),
'h', EndUtteranceCommand(),
'e', EndUtteranceCommand(),
'l', EndUtteranceCommand(),
'l', EndUtteranceCommand(),
'o', EndUtteranceCommand(),
CharacterModeCommand(False),
'bang', EndUtteranceCommand()
])
output = _getSpellingSpeechAddCharMode(seq, useSpellingFunctionality = True)
self.assertEqual(repr(list(output)), expected) You would also add a test for |
@feerrenrut, I have added unit tests for Regarding Regarding Thanks! |
Yes. Since you know that there are variations that must be handled, you could do it like that. Rather than call it a French test, which implies that locale is being set, I'd say "test variations on placeholder position (which occurs in other languages like French)". It would be good the code didn't have to deconstruct those strings for these variations. I don't fully understand the need for it and was hoping that the unit tests will demonstrate it to me.
Yes, please do. Since you have taken the time to understand it, and what the expected output is, it would be great to document that via unit tests.
While it might not immediately seem like it, I think it is a good thing to expose the underlying complexity. The fact is that this code depends on many variables. It is better for this to be explicit. One additional advantage is that it is then clear that it doesn't also modify config. |
The 'cap %s' string has to be deconstructed in some way because:
OK, will do. |
See test results for failed build of commit 6b11603f1b |
As requested, I have refactored a bit For now I have skipped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have given some suggestions, let me know if you'd like more guidance.
…hPlaceHolderBefore skipped for now
See test results for failed build of commit bf01e4df41 |
Install a fake gettext translation class while overriding translation return values
@feerrenrut, thanks for your last commit. If you do not have any other point to comment, this PR is ready from my side. |
Use a tear down method (run for each test) instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @CyrilleB79
Link to issue number:
Fixes #11948
Summary of the issue:
As described in #11948, some letter with diacritic is not spelt correctly with some synth if "Say cap before capitale" is checked, e. g. 'À' is spelt 'cap A' instead of 'cap A grave'.
Looking at
getSpellingSpeech
function inspeech\__init__.py
, it appears that this is due to the fact that the string 'cap À' is passed to the synth in the speech sequence in such a case. But the synth is only asked to use character mode for the strings whose length is 1. This is wrong in this case, because 'cap' should be spoken with character mode off, but 'À' should be spoken with character mode on.Description of how this pull request fixes the issue:
In
getSpellingSpeech
, in the string sequence, I have separated the 'cap' message string from the character to be spelt. If the character to be spelt is of length 1, i.e. not replaced by symbol description or modified pronunciation, character mode is activated. If a string in the speech sequence has a length > 1, because it is a capitalization message or because it corresponds to a character description or symbol replacement, character mode is disabled.Note that the 'cap' message can be of two types:
Thus this message is split in 2 parts in the speech sequence.
I have also taken advantage of the rework I had to do in
getSpellingSpeech
to split this function that was too complex. I have thus removed the corresponding flake8 exception (noqa comment).Testing performed:
Known issues with pull request:
that this assumption is verified in all the existing translations of NVDA.
If this does not seems robust enough, I may add a unit test such as the check_pot to check in all the .po files that this condition is met. Just let me know.
Change log entry:
Section: Bug fixes
NVDA should no longer spell incorrectly some letters with accents or other diacritic if 'Say cap before capitale' option is checked. (#11948)