def runtests(*test_args, **kwargs): if not test_args: test_args = ['tests'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) run(argv=sys.argv)
def run(*arg, **kw): """DEPRECATED: moved to nose.plugins.plugintest. """ import warnings warnings.warn("run() has been moved to nose.plugins.plugintest. Please " "update your imports.", category=DeprecationWarning, stacklevel=2) from nose.plugins.plugintest import run run(*arg, **kw)
def run(*arg, **kw): """DEPRECATED: moved to nose.plugins.plugintest. """ import warnings warnings.warn( "run() has been moved to nose.plugins.plugintest. Please " "update your imports.", category=DeprecationWarning, stacklevel=2) from nose.plugins.plugintest import run run(*arg, **kw)
def runtests(*test_args, **kwargs): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['tests'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) run(argv=sys.argv)
def runtests(settings): from django.test.utils import get_runner show_settings(settings, 'tests') TestRunner = get_runner(settings) test_runner = TestRunner(interactive=False) test_runner.setup_test_environment() old_config = test_runner.setup_databases() # Run tests with whatever argument was passed to the script run(argv=sys.argv) test_runner.teardown_databases(old_config) test_runner.teardown_test_environment()
dtime = (timeend - starttime).seconds sql = ''' INSERT INTO `longtest`.`result`(`id`, `name`, `request`, `respons`, `starttime`, `endtime`, `status`, `date`,`D_time`) VALUES (null, '{namepro}', '', '', '{timestart}', '{timeend}', '{status}','{timeend}', '{D_time}'); ''' sql = sql.format(namepro="pushdownTest_ssb", request1=str(response.url), respons1=str(response.text), timestart=starttime, timeend=timeend, D_time=dtime, status=str(response.status_code)) pushdownTest_ssb.cur.execute(sql) pushdownTest_ssb.conn.commit() self.assertEqual( response.status_code, 200, "uri = " + response.url + ' ' + "payload = " + str(payload) + ' ' + "status_code = " + str(response.status_code) + ' ' + 'response = ' + str(response.text)) self.assertEqual( json.loads(response.text)['code'], '000', "uri = " + response.url + ' ' + "payload = " + str(payload) + ' ' + "status_code = " + str(response.status_code) + ' ' + 'response = ' + str(response.text)) time.sleep(random.randint(1, 6)) if __name__ == '__main__': test_suite = unittest.TestSuite() test_suite.addTest(unittest.makeSuite(pushdownTest_ssb)) run(test_suite)
|""""""|''', r""" ,,~~--___---, / .~, / _,~ ) (_-(~) ~, ),,,( /' Z6 .~`' || \ | /_,/ || || ~~~~~~~~~~~~W`~~~~~~W`~~~~~~~~~""" ] class GoatPlugin(Plugin): enabled = True name = "goat-plugin" def options(self, parser, env=os.environ): parser.add_option('', '--no-goat', help='do not use the goat', action='store_true' ) def configure(self, options, conf): self.enabled = not options.no_goat def begin(self): sys.stderr.write("%(goat)s\n" % {'goat': random.choice(GOATS)}) if __name__ == '__main__': run(plugins=[GoatPlugin()])
@timed(2) def test_time(self): time.sleep(1) @timed(3) @attr(speed='slow') #run commend: #only slow: nosetests test_xxxx.py -A "speed == 'slow'" -v #not include slow: nosetests test_xxxx.py -A "speed != 'slow'" -v (fix the doc of nose) def test_time1(self): time.sleep(2) #no decorator #function name must be test_A, check_A #total 100 test def test_event(self): for i in range(100): yield self.check_event, i, (100 - i) def check_event(self, a, b): assert a + b == 100 #use the run_buffered from nose.plugins.plugintest to run in script instead from shell #in this method, some results have been removed if __name__ == '__main__': file = os.path.join(os.path.dirname(__file__), 'mynosetest.py') run(argv=['nosetests', '-v', file]) #run(argv=['nosetests', '-v', file], plugins=[ConfigMyTest()]) result = nose.run(TestT) #print(result)
// || ^^ ^^""" GOAT_2 = r""" /\\//\ _____\(oo)/ / --\/ \ ____|| || || ^^ ^^""" class GoatPlugin(Plugin): enabled = True name = "goat-plugin" def options(self, parser, env=os.environ): parser.add_option('', '--no-goat', help='do not use the goat', action='store_true' ) def configure(self, options, conf): self.enabled = not options.no_goat def begin(self): sys.stderr.write(GOAT_1) if __name__ == '__main__': run(plugins=[GoatPlugin()])