Skip to content

Commit bba924d

Browse files
author
Release Manager
committed
sagemathgh-38122: `sage.doctest.control`: In doctests, use Python floats for stats <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Hopefully fixes sagemath#38116 @jhpalmieri ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38122 Reported by: Matthias Köppe Reviewer(s):
2 parents 22da2bc + 3947d9a commit bba924d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/sage/doctest/control.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def load_stats(self, filename):
724724
sage: import json
725725
sage: filename = tmp_filename()
726726
sage: with open(filename, 'w') as stats_file:
727-
....: json.dump({'sage.doctest.control':{'walltime':1.0r}}, stats_file)
727+
....: json.dump({'sage.doctest.control': {'walltime': 1.0r}}, stats_file)
728728
sage: DC.load_stats(filename)
729729
sage: DC.stats['sage.doctest.control']
730730
{'walltime': 1.0}
@@ -759,7 +759,7 @@ def save_stats(self, filename):
759759
760760
sage: from sage.doctest.control import DocTestDefaults, DocTestController
761761
sage: DC = DocTestController(DocTestDefaults(), [])
762-
sage: DC.stats['sage.doctest.control'] = {'walltime':1.0r}
762+
sage: DC.stats['sage.doctest.control'] = {'walltime': 1.0r}
763763
sage: filename = tmp_filename()
764764
sage: DC.save_stats(filename)
765765
sage: import json
@@ -1034,8 +1034,8 @@ def filter_sources(self):
10341034
sage: DC = DocTestController(DD, [dirname])
10351035
sage: DC.expand_files_into_sources()
10361036
sage: for i, source in enumerate(DC.sources):
1037-
....: DC.stats[source.basename] = {'walltime': 0.1*(i+1)}
1038-
sage: DC.stats['sage.doctest.control'] = {'failed':True,'walltime':1.0}
1037+
....: DC.stats[source.basename] = {'walltime': 0.1r * (i+1)}
1038+
sage: DC.stats['sage.doctest.control'] = {'failed': True, 'walltime': 1.0r}
10391039
sage: DC.filter_sources()
10401040
Only doctesting files that failed last test.
10411041
sage: len(DC.sources)
@@ -1065,7 +1065,7 @@ def sort_sources(self):
10651065
sage: DC.expand_files_into_sources()
10661066
sage: DC.sources.sort(key=lambda s:s.basename)
10671067
sage: for i, source in enumerate(DC.sources):
1068-
....: DC.stats[source.basename] = {'walltime': 0.1*(i+1)}
1068+
....: DC.stats[source.basename] = {'walltime': 0.1r * (i+1)}
10691069
sage: DC.sort_sources()
10701070
Sorting sources by runtime so that slower doctests are run first....
10711071
sage: print("\n".join(source.basename for source in DC.sources))
@@ -1206,7 +1206,7 @@ def cleanup(self, final=True):
12061206
sage: DC.sources.sort(key=lambda s:s.basename)
12071207
12081208
sage: for i, source in enumerate(DC.sources):
1209-
....: DC.stats[source.basename] = {'walltime': 0.1*(i+1)}
1209+
....: DC.stats[source.basename] = {'walltime': 0.1r * (i+1)}
12101210
....:
12111211
12121212
sage: DC.run()

src/sage/doctest/forker.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def report_success(self, out, test, example, got, *, check_duration=0):
13701370
sage: FDS = FileDocTestSource(filename, DD)
13711371
sage: doctests, extras = FDS.create_doctests(globals())
13721372
sage: ex = doctests[0].examples[0]
1373-
sage: ex.walltime = 0.0
1373+
sage: ex.walltime = 0.0r
13741374
sage: DTR.report_success(sys.stdout.write, doctests[0], ex, '1764')
13751375
ok [0.00 s]
13761376
"""
@@ -1543,8 +1543,8 @@ def report_overtime(self, out, test, example, got, *, check_duration=0):
15431543
sage: FDS = FileDocTestSource(filename, DD)
15441544
sage: doctests, extras = FDS.create_doctests(globals())
15451545
sage: ex = doctests[0].examples[0]
1546-
sage: ex.walltime = 1.23
1547-
sage: DTR.report_overtime(sys.stdout.write, doctests[0], ex, 'BAD ANSWER\n', check_duration=2.34)
1546+
sage: ex.walltime = 1.23r
1547+
sage: DTR.report_overtime(sys.stdout.write, doctests[0], ex, 'BAD ANSWER\n', check_duration=2.34r)
15481548
**********************************************************************
15491549
File ".../sage/doctest/forker.py", line 12, in sage.doctest.forker
15501550
Warning, slow doctest:
@@ -1674,11 +1674,12 @@ def update_results(self, D):
16741674
sage: DTR.run(doctests[0])
16751675
TestResults(failed=0, attempted=4)
16761676
sage: T.stop().annotate(DTR)
1677-
sage: D = DictAsObject({'cputime':[],'walltime':[],'err':None})
1677+
sage: D = DictAsObject({'cputime': [], 'walltime': [], 'err': None})
16781678
sage: DTR.update_results(D)
16791679
0
16801680
sage: sorted(list(D.items()))
1681-
[('cputime', [...]), ('err', None), ('failures', 0), ('tests', 4), ('walltime', [...]), ('walltime_skips', 0)]
1681+
[('cputime', [...]), ('err', None), ('failures', 0), ('tests', 4),
1682+
('walltime', [...]), ('walltime_skips', 0)]
16821683
"""
16831684
for key in ["cputime", "walltime"]:
16841685
if key not in D:

0 commit comments

Comments
 (0)