Login | Register
My pages Projects Community openCollabNet

Discussions > users > [maxq-users] multiple directories for tests

Discussion topic

Back to topic list

[maxq-users] multiple directories for tests

Author christophe blin <cblin at tennaxia dot com>
Full name christophe blin <cblin at tennaxia dot com>
Date 2005-04-13 08:25:29 PDT
Message Hi,

I want to modularize my test scripts.
So I have multiple files : action_login.py to log on my app,
valid_home.py to check that the current page is the home page
and the file doing the test test_login.py.
action_* and valid_* are so reusable in all the tests (ex: having a
test_logout.py calling first action_login then valid_home and finally
doing the disconnection)

When all the files are in the same directory, the script is perfectly
working (action_login and valid_home are correctly imported).
What I did not manage to do is to put the files in different directories.
ex :

when executing in the tests directory :
$>..\maxq-0.98\bin\maxq -r test_login.py
13 avr. 2005 16:55:30 com.bitmechanic.maxq.Main runTests
INFO: Running: test_login.py
Traceback (innermost last):
  File "test_login.py", line 6, in ?
ImportError: cannot import name action_login

I have tried to replace the test_login.py, line 6 ('import
action_login') by
    'from common import action_login'
    'from common.action_login import action_login'

But none are working ! I do not understand how the modules are imported
because doing
"from org.python.modules import re" is working with this class in jython.jar

Any help appreciated.

action_login.py :
# login into XXX with (thelogin, thepwd) for (login, password)
def login(test, thelogin, thepwd):
        params = [
            ('''id_lien''', ''''''),
            ('''reso''', '''1280x1024; ColorDepth=32'''),
            ('''login_auth''', thelogin),
            ('''password_auth''', thepwd),
            ('''authentication''', '''Validez'''),]
        test.msg("Testing login")
        url = "http://wwwdev-mysql4​0/private/index.php"
        test.post(url, params)
        test.msg("Response code: %s" % test.getResponseCode())
        test.assertEquals("Assert login failed", 200,

valid_home.py :
# validate that the main frame is the home page
def validHomePage(test):
    params = [
        ('''frameset''', '''main'''),]
    test.msg("Testing home page")
    url = "http://wwwdev-mysql4​0/private/index.php"
    test.get(url, params)
    test.msg("Response code: %s" % test.getResponseCode())
    test.assertEquals("Assert test home page failed (bad code)", 200,
    test.assertTrue("Assert test home page failed",
test_login.py :
# A test to check that after a succesful login we go to the home page
from PyHttpTestCase import PyHttpTestCase

import action_login
import valid_home
import valid_menu

# definition of test class
class testLogin(PyHttpTestCase):

    def runTest(self):
        self.msg('Test login started')
        action_login.login(self, 'usr', 'pwd')

# Code to load and run the test
if __name__ == 'main':
    test = testLogin("connexion test")

To unsubscribe, e-mail: users-unsubscribe@ma​xq.tigris.org
For additional commands, e-mail: users-help at maxq dot tigris dot org

« Previous message in topic | 1 of 3 | Next message in topic »


Show all messages in topic

[maxq-users] multiple directories for tests christophe blin <cblin at tennaxia dot com> christophe blin <cblin at tennaxia dot com> 2005-04-13 08:25:29 PDT
     Re: [maxq-users] multiple directories for tests oliverbock Oliver Bock 2005-04-13 17:15:02 PDT
         Re: [maxq-users] multiple directories for tests christophe blin <cblin at tennaxia dot com> christophe blin <cblin at tennaxia dot com> 2005-04-14 01:34:40 PDT
Messages per page: