This is an archive of the discontinued Mercurial Phabricator instance.

py3: replace print() with assert in test-demandimport.py
ClosedPublic

Authored by indygreg on Feb 1 2019, 7:48 PM.

Details

Summary

Behavior of demand imports behaves differently between Python 2 and 3.
.out files do not support conditional output the way that .t files do.
In order to make this test work on Python 3, we'll need to make the
test itself conditional.

The first step of this is to port the test to not use a .out file
to compare output.

Unfortunately, we can't easily use the unittest framework for
defining this test because putting import statements in functions
changes the behavior of the demand importer (at least on Python 2).
So, we effectively replace a bunch of print() with assert statements.

This makes the test a bit annoying to debug, as the test will
stop at first assertion failure. But we don't exactly have
a good alternative.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Feb 1 2019, 7:48 PM
This revision was automatically updated to reflect the committed changes.
tests/test-demandimport.py