#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" fromsys.pathinstead ofos.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)
Change History (15)
by , 17 years ago
| Attachment: | 8047_admin_scripts_tests_on_jython.diff added | 
|---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
 os.pathsep  should contain the appropriate string for seperating paths in PYTHONPATH.
comment:3 by , 17 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.
by , 17 years ago
| Attachment: | 8047_admin_scripts_tests_on_jython.2.diff added | 
|---|
comment:4 by , 17 years ago
follow-up: 6 comment:5 by , 17 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?
comment:6 by , 17 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 , 17 years ago
| Attachment: | 8047_admin_scripts_tests_on_jython.3.diff added | 
|---|
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 , 17 years ago
can i also suggest, while you're at it,  to remove the 'Optimized' python bits "*.pyo"?
by , 17 years ago
| Attachment: | 8047_admin_scripts_tests_on_jython.5.diff added | 
|---|
I screwed up the patch the last time. Now it is ok
comment:8 by , 17 years ago
| Owner: | changed from to | 
|---|---|
| Triage Stage: | Unreviewed → Accepted | 
comment:9 by , 17 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
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).