-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix some tests for Python 3.3 #1748
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
Changes from all commits
1ccffcb
6fb51bd
62dafda
040d936
fe1c7d7
7fcb72b
bb6dab9
463265c
f0a0234
cf0836b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,8 +417,9 @@ def __init__(self, argv=None, aliases=None, flags=None): | |
|
|
||
| >>> from IPython.config.loader import KeyValueConfigLoader | ||
| >>> cl = KeyValueConfigLoader() | ||
| >>> cl.load_config(["--A.name='brian'","--B.number=0"]) | ||
| {'A': {'name': 'brian'}, 'B': {'number': 0}} | ||
| >>> d = cl.load_config(["--A.name='brian'","--B.number=0"]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following up with the previous line: if it's awkward for this to pass as a doctest, I'd rather just remove it from being a doctest (leave it as an example, mark it with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no runtime cost in this case, because the sorting's in a docstring, but I can skip_doctest it if you prefer to keep the example clean.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries, I only meant it if it would cause you extra grief to make the doctests pass. I don't think that is too bad in that mode, so I'm fine leaving it. |
||
| >>> sorted(d.items()) | ||
| [('A', {'name': 'brian'}), ('B', {'number': 0})] | ||
| """ | ||
| self.clear() | ||
| if argv is None: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -774,7 +774,12 @@ def timeit(self, line='', cell=None): | |
| setup = timeit.reindent(stmt, 4) | ||
| stmt = timeit.reindent(cell, 8) | ||
|
|
||
| src = timeit.template % dict(stmt=stmt, setup=setup) | ||
| # From Python 3.3, this template uses new-style string formatting. | ||
| if sys.version_info >= (3, 3): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why make this version dependent? It seems to me we could just move to the new form for all versions, since
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, got it. Then yes, leave it. |
||
| src = timeit.template.format(stmt=stmt, setup=setup) | ||
| else: | ||
| src = timeit.template % dict(stmt=stmt, setup=setup) | ||
|
|
||
| # Track compilation time so it can be reported if too long | ||
| # Minimum time above which compilation time will be reported | ||
| tc_min = 0.1 | ||
|
|
||
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.
No, this adds cost to all instances only for the benefit of a doctest. Instead, the test should be changed, to not depend on the order (it can do a
setcheck on both keys and values, for example.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.
Note that this affects how the options for help are printed - I think it's awkward to have the options displayed in a random order each time you do something like
ipython --help-all.Given that this method is only called to display help information (
class_get_help()), I think the cost of Python's built in sort is going to be negligible compared to the speed with which output can be written. This was probably the place I was most confident that sorting was the right way to go.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.
Ah, I didn't realize this was inside of a method called for interactive help, sorry. For some reason I thought it was in the constructor itself and that it would thus affect everything all the time.
Yes, I agree that if it's only invoked interactively at help time, it's OK. Sorry for the misfire.