devtools/cwwindmill.py
changeset 7059 1d65b235549f
parent 6438 abae10f81a85
child 7061 bb2080547722
equal deleted inserted replaced
7049:f2ae6202754c 7059:1d65b235549f
    75     (services transformer) instead of the windmill sub-directory
    75     (services transformer) instead of the windmill sub-directory
    76     You can change `test_dir` as following:
    76     You can change `test_dir` as following:
    77 
    77 
    78         test_dir = __file__
    78         test_dir = __file__
    79 
    79 
    80     Instead of toggle `edit_test` value, try `pytest -i`
    80     Instead of toggle `edit_test` value, try `python <test script> -f`
    81     """
    81     """
    82     browser = 'firefox'
    82     browser = 'firefox'
    83     edit_test = "-i" in sys.argv # detection for pytest invocation
    83     edit_test = "-f" in sys.argv or "-i" in sys.argv # XXX pytest
    84     # Windmill use case are written with no anonymous user
    84     # Windmill use case are written with no anonymous user
    85     anonymous_logged = False
    85     anonymous_logged = False
    86 
    86 
    87     def _test_dir(self):
    87     def _test_dir(self):
    88         """access to class attribute if possible or make assumption
    88         """access to class attribute if possible or make assumption
    97                 test_dir = os.path.dirname(inspect.stack()[-1][1])
    97                 test_dir = os.path.dirname(inspect.stack()[-1][1])
    98             return osp.join(test_dir, 'windmill')
    98             return osp.join(test_dir, 'windmill')
    99 
    99 
   100     def setUp(self):
   100     def setUp(self):
   101         # Start CubicWeb session before running the server to populate self.vreg
   101         # Start CubicWeb session before running the server to populate self.vreg
   102         CubicWebServerTC.setUp(self)
   102         super(CubicWebWindmillUseCase, self).setUp()
   103         # XXX reduce log output (should be done in a cleaner way)
   103         # XXX reduce log output (should be done in a cleaner way)
   104         # windmill fu** up our logging configuration
   104         # windmill fu** up our logging configuration
   105         for logkey in ('windmill', 'logilab', 'cubicweb'):
   105         for logkey in ('windmill', 'logilab', 'cubicweb'):
   106             getLogger(logkey).setLevel(ERROR)
   106             getLogger(logkey).setLevel(ERROR)
   107         self.test_dir = self._test_dir()
   107         self.test_dir = self._test_dir()
   116                 windmill.settings[setting] = value
   116                 windmill.settings[setting] = value
   117         self.windmill_shell_objects = setup()
   117         self.windmill_shell_objects = setup()
   118 
   118 
   119     def tearDown(self):
   119     def tearDown(self):
   120         teardown(self.windmill_shell_objects)
   120         teardown(self.windmill_shell_objects)
   121         CubicWebServerTC.tearDown(self)
   121         super(CubicWebWindmillUseCase, self).tearDown()
   122 
   122 
   123     def testWindmill(self):
   123     def testWindmill(self):
   124         if self.edit_test:
   124         if self.edit_test:
   125             # see windmill.bin.admin_options.Firebug
   125             # see windmill.bin.admin_options.Firebug
   126             windmill.settings['INSTALL_FIREBUG'] = 'firebug'
   126             windmill.settings['INSTALL_FIREBUG'] = 'firebug'