[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #14076 [Stem]: Fix tutorial_examples.py to not relay on correct ordering.
#14076: Fix tutorial_examples.py to not relay on correct ordering.
-------------------------+-------------------------------------------------
Reporter: | Owner: atagar
Foxboron | Status: new
Type: defect | Milestone:
Priority: normal | Version:
Component: Stem | Keywords: python, tests, tutorial, examples,
Resolution: | 2, 3
Actual Points: | Parent ID:
Points: |
-------------------------+-------------------------------------------------
Comment (by atagar):
Gotcha. We should definitely fix any ordering dependency though have you
thought of doing something like the following instead?
{{{
def assert_equal_unordered(self, expected, actual):
self.assertListEqual(expected.splitlines(), actual.splitlines())
self.assert_equal_unordered(LIST_CIRCUITS_OUTPUT, stdout_output)
}}}
If we can't mock stdout that's a little unfortunate since I was thinking
about changing these tests to...
{{{
def test_foo():
... do necessary mocking...
with open('docs/tutorials/examples/foo') as docs_file:
... get the example code by looking for the '::' block
exec(example)
... do assertions...
}}}
This way when examples are updated the tests will reflect that (rather
than being duplicate code). This makes me a tad nervous cuz... well,
exec(). But this might be a good use for it.
Removing our stdout mocks will take us a step away from being able to do
this.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/14076#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs