ANN: Python Test Environment

Discussion in 'Python' started by Fuzzyman, Dec 14, 2004.

  1. Fuzzyman

    Fuzzyman Guest

    Well sort of.......

    More a request for comments really - to see if anyone is interested in
    this.

    http://www.voidspace.org.uk/atlantibots/pythonutils.html#testenv

    I've created a script that will build a 'test environment'. Windoze(tm)
    only as it uses py2exe.

    It scans your Python\Lib folder and builds a script that *fakes* an
    import of every file. This *more* or less amounts to everything in the
    standard lib. There is then another script that turns this into a
    python executable.

    The result is an executable that will run any python script. It gives
    sensible values to sys.path, sys.argv and __file__.

    This is useful for two purposes :

    1) Easily have test environments for multiple versions of python - to
    test your scripts.
    2) Run any python script on a machine without python installed.


    Usage :

    testenv <python file> arg1 arg2...

    Which should be the equivalent of :
    python <python file> arg1 arg2...


    Sample output :
    (Built with Python 2.4 - then 2.3 - prints sys.version first)

    ########


    D:\New Folder\testenv>testenv test.py arg1 arg2 arg3
    2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]

    sys.path = ['D:\\New Folder\\testenv\\library.zip', 'D:\\New
    Folder\\testenv', '
    D:\\New Folder\\testenv']

    sys.argv = ['D:\\New Folder\\testenv\\test.py', 'arg1', 'arg2', 'arg3']

    import Tkinter # succeeded

    import dummylibrary # succeeded

    D:\New Folder\testenv>


    ##########

    D:\Python Projects\modules in progress\py2exe-testenv\dist>testenv
    test.py arg1
    arg2
    2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)]

    sys.path = ['D:\\Python Projects\\modules in
    progress\\py2exe-testenv\\dist\\lib
    \\shared.zip', 'D:\\Python Projects\\modules in
    progress\\py2exe-testenv\\dist',
    'D:\\Python Projects\\modules in progress\\py2exe-testenv\\dist']

    sys.argv = ['D:\\Python Projects\\modules in
    progress\\py2exe-testenv\\dist\\tes
    t.py', 'arg1', 'arg2']

    import Tkinter # succeeded

    import dummylibrary # succeeded

    D:\Python Projects\modules in progress\py2exe-testenv\dist>

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I'm sure this can be improved in lots of ways - only about an hours
    hacking or so - but already useful to me. Comments and suggestions for
    improvements welcomed.

    Regards,


    Fuzzy
     
    Fuzzyman, Dec 14, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fuzzyman

    ANN: Python Test Environment

    Fuzzyman, Dec 14, 2004, in forum: Python
    Replies:
    0
    Views:
    291
    Fuzzyman
    Dec 14, 2004
  2. Fuzzyman

    ANN: Python Test Environment

    Fuzzyman, Dec 15, 2004, in forum: Python
    Replies:
    0
    Views:
    319
    Fuzzyman
    Dec 15, 2004
  3. Michael Foord

    ANN: Python Test Environment

    Michael Foord, Dec 15, 2004, in forum: Python
    Replies:
    2
    Views:
    298
  4. Replies:
    5
    Views:
    660
  5. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    706
    Skybuck Flying
    Oct 4, 2009
Loading...

Share This Page