Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8047 closed (fixed)

admin_scripts tests doesn't work on Jython

Reported by: Leo Soto M. Owned by: Jacob
Component: Testing framework Version: dev
Severity: Keywords: jython
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This set of tests rely on the PYTHONPATH environment variable to set the sys.path of the child python processes it launches and to read the potential location of external backends. But Jython doesn't use PYTHONPATH (nor does IronPython, for the record).

The attached patch fixes this by:

  • Tweaking the command line to be executed depending on the current platform.
  • Reading the "current PYTHONPATH" from sys.path instead of os.environ['PYTHONPATH'].

It also contains code to remove the compiled files generated from Jython, and avoids a check for the "pyc" extension on the output.

The only drawback I can see is that by using sys.path instead of PYTHONPATH, I've incremented the number places where a pre-existing 'settings.py' file would break the test. Practical example: a settings.py file under <django-root>/tests/.

If it is considered to be worth the effort, this patch could be improved by trying to point the the child's sys.path to only <django-root>, <django-root>/tests/regressiontests/ and <external-backend-root>.

Attachments (5)

8047_admin_scripts_tests_on_jython.diff (4.0 KB ) - added by Leo Soto M. 16 years ago.
8047_admin_scripts_tests_on_jython.2.diff (3.8 KB ) - added by Leo Soto M. 16 years ago.
8047_admin_scripts_tests_on_jython.3.diff (4.2 KB ) - added by Leo Soto M. 16 years ago.
Avoid inheriting the whole sys.path, to the child processes. Now it just tries to detect the location of the external backend.
8047_admin_scripts_tests_on_jython.4.diff (2.6 KB ) - added by Leo Soto M. 16 years ago.
updated to svn r8162
8047_admin_scripts_tests_on_jython.5.diff (2.4 KB ) - added by Leo Soto M. 16 years ago.
I screwed up the patch the last time. Now it is ok

Download all attachments as: .zip

Change History (15)

by Leo Soto M., 16 years ago

comment:1 by Leo Soto M., 16 years ago

Crap, I just realized that the current patch will break the suite on windows where the commandline "PYTHONPATH=foo python" is very likely going to fail (don't have a windows box to confirm it right now).

comment:2 by Alex Gaynor, 16 years ago

os.pathsep should contain the appropriate string for seperating paths in PYTHONPATH.

comment:3 by Leo Soto M., 16 years ago

Well, I didn't explained well enough

With "PYTHONPATH=foo python" I tried to set the python path to foo and launch python in one shot. This way I didn't needed to mess with os.environ['PYTHONPATH'] and only _sys_executable had to deal with different Python VMs.

But it won't work on Windows, so I'm reverting that particular approach on this new patch.

comment:4 by Russell Keith-Magee, 16 years ago

(In [8158]) Refs #8047 -- Removed some CPython specific parts of the admin scripts tests.

comment:5 by Russell Keith-Magee, 16 years ago

The sys.path path of the proposed patch doesn't work for me; sys.path includes a lot of things that PYTHONPATH doesn't contain - in particular, the tests directory itself, which causes some of the tests to fail. Any other suggestions for composing PYTHONPATH?

in reply to:  5 comment:6 by Leo Soto M., 16 years ago

Replying to russellm:

The sys.path path of the proposed patch doesn't work for me; sys.path includes a lot of things that PYTHONPATH doesn't contain - in particular, the tests directory itself, which causes some of the tests to fail.

Yeah, that was what I tried to explain on the last two paragraph of the ticket description. The new patch detect where the external backend is located and only adds its parent directory to the child's sys.path.

by Leo Soto M., 16 years ago

Avoid inheriting the whole sys.path, to the child processes. Now it just tries to detect the location of the external backend.

comment:7 by magneto, 16 years ago

can i also suggest, while you're at it, to remove the 'Optimized' python bits "*.pyo"?

by Leo Soto M., 16 years ago

updated to svn r8162

by Leo Soto M., 16 years ago

I screwed up the patch the last time. Now it is ok

comment:8 by Eric Holscher, 16 years ago

Owner: changed from nobody to Jacob
Triage Stage: UnreviewedAccepted

comment:9 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [8238]) Fixed #8047: property detect an external database backend and set sys.path accordingly. Patch from Leo Soto.

comment:10 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top