[pacman-dev] [PATCH 0/8] Wondering if Python 3 could run the tests?

Jeremy Heiner scalaprotractor at gmail.com
Wed Oct 9 20:35:03 EDT 2013


The short answer is: yes, it can.

The slightly longer answer is: with these patches the test framework
is compatible with any Python from 2.5 up to 3.3. Relax: none of these
patches actually change which version gets used during a build. This
is just an exploration of what is needed to get over the bump from
Python 2 to 3.

This experiment came about as I was working on the -Qk(k) unit tests.
I realized that I had used a 2.7 specific feature, and I stopped to
grep through the code and the mailing list to see if that was a no-no.
That lead me to trying out 2.6 and then 2.5 to see what version the
framework needed. Patch 1 is about that lower end of the scale.

This naturally got me wondering about the upper end and how much pain
it would be to move in that direction. Python offers tools to help
migration. Patch 2 came from running "python2 -3". And patches 3 thru
7 came from "2to3" (split into commits by the specific issue).  After
those the code was syntactically acceptable to 3.3, and so the last
two issues, fixed in Patch 8, came from runtime exceptions.

Most of the difficult work was setting up a test environment for the
pactest framework so I could be assured that the changes suggested by
the migration tools wouldn't break anything. And splitting up what
"2to3" reported into commits that would make sense.

I am ambivalent on the prosepect of accepting these patches into the
code base. Python 2.7 isn't going to disappear tomorrow, so there's no
fire. There are no features in 3.x that are must-have solutions to a
pain point. Nothing's really broken, so these patches aren't really
fixing anything. All very true.

The only advantage I can think of is that it might entice more people
into writing more tests if they could use they shiny (overly hyped?)
new 3.x features instead of that old boring 2.7 stuff.

At the very least I would suggest that it would be very helpful to
explicitly state somewhere in the test framework code the minimum
version needed. I've determined it could be set to 2.5 (no, I did not
check lower than that), but it would make much more sense to pick 2.7.

Assuming, that is, that the consensus will be that jumping to 3.x is a
bridge too far.

Jeremy Heiner (8):
  Restore ability to run tests with version 2.5 of Python.
  Use Python's "exec" instead of deprecated "execfile".
  Python 3 octal literals broke backwards compatibility.
  Add shims to return views on Python dicts.
  Add shims to return a new Python StringIO instance.
  Use Python's "range" instead of deprecated "xrange".
  Add parens around tuples in Python for comprehensions.
  Allow tests to be run with either version 2 or 3 of Python.

 test/pacman/pmdb.py                  |  7 +++---
 test/pacman/pmpkg.py                 | 11 +++++----
 test/pacman/pmtest.py                | 14 +++++++----
 test/pacman/tests/depconflict100.py  |  2 +-
 test/pacman/tests/depconflict120.py  |  2 +-
 test/pacman/tests/epoch005.py        |  2 +-
 test/pacman/tests/fileconflict001.py |  2 +-
 test/pacman/tests/fileconflict002.py |  2 +-
 test/pacman/tests/query006.py        |  3 +--
 test/pacman/tests/remove052.py       |  2 +-
 test/pacman/tests/smoke001.py        |  4 +--
 test/pacman/tests/smoke003.py        |  4 +--
 test/pacman/tests/sync030.py         |  2 +-
 test/pacman/tests/sync031.py         |  2 +-
 test/pacman/tests/sync040.py         |  2 +-
 test/pacman/tests/sync041.py         |  2 +-
 test/pacman/tests/sync405.py         |  2 +-
 test/pacman/tests/sync406.py         |  2 +-
 test/pacman/tests/sync891.py         |  2 +-
 test/pacman/tests/sync892.py         |  2 +-
 test/pacman/tests/sync893.py         |  2 +-
 test/pacman/tests/sync898.py         |  2 +-
 test/pacman/tests/sync990.py         |  2 +-
 test/pacman/tests/sync992.py         |  2 +-
 test/pacman/tests/upgrade005.py      |  2 +-
 test/pacman/tests/upgrade013.py      |  2 +-
 test/pacman/tests/upgrade014.py      |  2 +-
 test/pacman/tests/upgrade030.py      |  2 +-
 test/pacman/tests/upgrade031.py      |  2 +-
 test/pacman/tests/upgrade032.py      |  2 +-
 test/pacman/tests/upgrade040.py      |  2 +-
 test/pacman/tests/upgrade041.py      |  2 +-
 test/pacman/tests/upgrade042.py      |  2 +-
 test/pacman/tests/upgrade043.py      |  2 +-
 test/pacman/tests/upgrade046.py      |  2 +-
 test/pacman/tests/upgrade050.py      |  2 +-
 test/pacman/tests/upgrade059.py      |  2 +-
 test/pacman/tests/upgrade060.py      |  2 +-
 test/pacman/tests/upgrade061.py      |  2 +-
 test/pacman/tests/upgrade073.py      |  2 +-
 test/pacman/tests/upgrade090.py      |  2 +-
 test/pacman/tests/xfercommand001.py  |  2 +-
 test/pacman/util.py                  | 47 ++++++++++++++++++++++++++++++------
 43 files changed, 99 insertions(+), 63 deletions(-)

-- 
1.8.4



More information about the pacman-dev mailing list