Skip to content
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

Bug: Config tests failing in Windows 10 #453

Open
awmacpherson opened this issue Oct 7, 2022 · 1 comment
Open

Bug: Config tests failing in Windows 10 #453

awmacpherson opened this issue Oct 7, 2022 · 1 comment

Comments

@awmacpherson
Copy link

The unit tests in the Config class in wormhole.test.test_args fail in Windows 10 when running all tests (i.e. python -m wormhole.test.run_trial wormhole) but succeed when running only the tests in test_args (as in python -m wormhole.test.run_trial wormhole.test.test_args).

Failing output:

...
    test_write_when_closing ...                                            [OK]
wormhole.test.test_args
  Config
    test_receive ...                                                     [FAIL]
    test_send ...                                                        [FAIL]
  Receive
    test_accept_file ...                                                   [OK]
    test_appid ...                                                         [OK]
...
[lots of tests]
...
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "c:\users\user\repo\magic-wormhole\src\wormhole\test\test_args.py", line 202, in test_receive
    self.assertEqual(cfg.stdout, sys.stdout)
  File "C:\Users\user\repo\magic-wormhole\.tox\py38\lib\site-packages\twisted\trial\_synctest.py", line 424, in assertEqual
    super().assertEqual(first, second, msg)
  File "C:\Python38\lib\unittest\case.py", line 912, in assertEqual
    assertion_func(first, second, msg=msg)
  File "C:\Python38\lib\unittest\case.py", line 905, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> != <colorama.ansitowin32.StreamWrapper object at 0x0000020D534E4EB0>

wormhole.test.test_args.Config.test_receive
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "c:\users\user\repo\magic-wormhole\src\wormhole\test\test_args.py", line 198, in test_send

    self.assertEqual(cfg.stdout, sys.stdout)
  File "C:\Users\user\repo\magic-wormhole\.tox\py38\lib\site-packages\twisted\trial\_synctest.py", line 424, in assertEqual
    super().assertEqual(first, second, msg)
  File "C:\Python38\lib\unittest\case.py", line 912, in assertEqual
    assertion_func(first, second, msg=msg)
  File "C:\Python38\lib\unittest\case.py", line 905, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> != <colorama.ansitowin32.StreamWrapper object at 0x0000020D534E4EB0>

wormhole.test.test_args.Config.test_send
-------------------------------------------------------------------------------
Ran 449 tests in 62.482s

FAILED (skips=1, expectedFailures=1, failures=2, successes=445)
ERROR: InvocationError for command 'C:\Users\user\repo\magic-wormhole\.tox\py38\Scripts\python.EXE' -m wormhole.test.run_trial wormhole (exited with code 1)
____________________________________________ summary _____________________________________________ ERROR:   py38: commands failed

This bizarre problem appears to be caused by colorama being loaded in some different set of tests and colorama.init() executed, changing the value of sys.stdout from the default <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> to a colorama.ansitowin32.StreamWrapper, a state that persists as long as the interpreter is running. Presumably, colorama is being loaded by click which has it among its dependencies.

I'd be happy to address this myself, but I'm not sure what the actual desired behaviour of these tests are. Perhaps the point is to check that the click app writes output to the calling shell's stdout? Are we happy to just check the filenos are the same?

@meejah
Copy link
Member

meejah commented Oct 11, 2022

I think those two tests are essentially just testing "test helper" code (i.e. that it ... doesn't override stdin/stdout as a result of that helper call?)

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

No branches or pull requests

2 participants