Opened 5 years ago

Closed 5 years ago

#8972 defect closed wontfix (wontfix)

`trial ...` and `python -m twisted.trial ...` result in significantly divergent `sys.path` values

Reported by: Jean-Paul Calderone Owned by: Craig Rodrigues
Priority: normal Milestone:
Component: trial Keywords:
Cc: Branch:
Author:

Description

(trialtest) exarkun@baryon:/tmp/trialthing$ trial --version
Twisted version: 16.6.0dev0
(trialtest) exarkun@baryon:/tmp/trialthing$ cat test_thing.py
import sys
import pprint

pprint.pprint(sys.path)

(trialtest) exarkun@baryon:/tmp/trialthing$ echo ${PYTHONPATH}

(trialtest) exarkun@baryon:/tmp/trialthing$ trial test_thing
test_thing ...                                                          [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/exarkun/Projects/twisted/src/twisted/trial/runner.py", line 602, in loadByNames
    things.append(self.findByName(name))
  File "/home/exarkun/Projects/twisted/src/twisted/trial/runner.py", line 406, in findByName
    return reflect.namedAny(name)
  File "/home/exarkun/Projects/twisted/src/twisted/python/reflect.py", line 306, in namedAny
    raise ModuleNotFound("No module named %r" % (name,))
twisted.python.reflect.ModuleNotFound: No module named 'test_thing'

test_thing
-------------------------------------------------------------------------------
Ran 1 tests in 0.012s

FAILED (errors=1)
(trialtest) exarkun@baryon:/tmp/trialthing$ python -m twisted.trial test_thing
['',
 '/tmp/trialtest/lib/python2.7',
 '/tmp/trialtest/lib/python2.7/plat-x86_64-linux-gnu',
 '/tmp/trialtest/lib/python2.7/lib-tk',
 '/tmp/trialtest/lib/python2.7/lib-old',
 '/tmp/trialtest/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/tmp/trialtest/local/lib/python2.7/site-packages',
 '/home/exarkun/Projects/twisted/src',
 '/tmp/trialtest/lib/python2.7/site-packages']

-------------------------------------------------------------------------------

PASSED
(trialtest) exarkun@baryon:/tmp/trialthing$ 

I can't quite find an explicit statement that the change of behavior to trial to exclude "" from sys.path was intentional - but I did find http://twistedmatrix.com/pipermail/twisted-python/2016-September/030780.html which discusses the parallel change in twistd and suggests it was intentional (or at least accidental but then desired).

In this case, making twistd -m twisted.trial ... agree with the desired behavior seems to make more sense than allowing the two to diverge, with the new (presumably desirable) version having the old (apparently undesirable) behavior.

Change History (6)

comment:1 Changed 5 years ago by Jean-Paul Calderone

Apparently this was discussed, perhaps on IRC, and the decision was made that not putting pwd in sys.path is the right thing to do.

It would be nice if someone involved in the discussion documented that rationale, though.

comment:2 Changed 5 years ago by Glyph

#8978 was a duplicate of this.

comment:3 Changed 5 years ago by Julian Berman

Owner: set to Craig Rodrigues

comment:4 Changed 5 years ago by Julian Berman

Keywords: review added

comment:5 Changed 5 years ago by Julian Berman

Keywords: review removed

comment:6 Changed 5 years ago by Julian Berman

Resolution: wontfix
Status: newclosed

At least one part of the rationale is in https://twistedmatrix.com/pipermail/twisted-python/2017-February/031145.html

Closing this out given that it sounds like consensus is to leave as-is.

Note: See TracTickets for help on using tickets.