def setUpClass(cls): for arg in sys.argv: if 'liveserver' in arg: cls.server_url = 'http://' + arg.split('=')[1] return # StaticLiveServerTestCase.setUpClass() cls.server_url = cls.live_server_url
def setUpClass(cls): for arg in sys.argv: if "liveserver" in arg: cls.server_url = "http://" + arg.split("=")[1] return StaticLiveServerTestCase.setUpClass() cls.server_url = cls.live_server_url
def setUpClass(cls): for arg in sys.argv: if 'liveserver' in arg: cls.server_url = 'http://' + arg.split('=')[1] return # # in python2 we should pass current class name to the super StaticLiveServerTestCase.setUpClass() cls.server_url = cls.live_server_url
def test_make_short_url(self): test_url = "https://www.jmr.pl/" homepage = HomePage(self.browser) homepage.navigate() homepage.fill_url(test_url) homepage.submit() short_url = homepage.get_url() final_url = get_final_url(self.browser, short_url) StaticLiveServerTestCase.assertEqual(self, test_url, final_url)
def handle(self, *args, **options): server = StaticLiveServerTestCase() server.setUpClass() server.setUp() crawler = Crawler() crawler.run(server.live_server_url) crawler.graph.save()
def setUpClass(cls): for arg in sys.argv: if 'liveserver' in arg: cls.server_host = arg.split('=')[1] cls.server_url = 'http://' + cls.server_host cls.against_staging = True return StaticLiveServerTestCase.setUpClass() cls.against_staging = False cls.server_url = cls.live_server_url
def start(self): super(DjangoServer, self).start() os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = \ '{address}:{port}'.format(address=self.address, port=self.port) LiveServerTestCase.setUpClass() print("Django's builtin server is running at {address}:{port}". format(address=self.address, port=self.port))
def start(self): super(DjangoServer, self).start() os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = \ '{address}:{port}'.format(address=self.address, port=self.port) LiveServerTestCase.setUpClass() print "Django's builtin server is running at {address}:{port}".format( address=self.address, port=self.port)
def setUpClass(cls): StaticLiveServerTestCase.setUpClass() # super(StaticLiveServerTestCase, cls).setUpClass() o1 = Organism(name="Organizm_testowy_1", id=1) o2 = Organism(name="Organizm_testowy_2", id=2) ch1 = Chromosome(organism=o1, number=1, length=40, id=1) ch2 = Chromosome(organism=o1, number=2, length=30, id=2) sc1 = Scaffold(chromosome=ch2, length=5, order=0, start=3, id=1) seq1 = Sequence(scaffold=sc1, sequence="AGTCA", id=1) sc2 = Scaffold(chromosome=ch2, length=7, order=1, start=11, id=2) seq2 = Sequence(scaffold=sc2, sequence="GTCAGTC", id=2) for obj in [o1, o2, ch1, ch2, sc1, seq1, sc2, seq2]: obj.save()
def start(self): super(DjangoServer, self).start() os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = \ '{address}:{port}'.format(address=self.address, port=self.port) LiveServerTestCase.setUpClass() # now get the actual port that the test case was allocated self.port = LiveServerTestCase.server_thread.port world.django_url = self.url print "Django's builtin server is running at {address}:{port}".format( address=self.address, port=self.port)
def setUpClass(cls): WithForm460ADataTest.setUpClass() StaticLiveServerTestCase.setUpClass() cls.username = '******' cls.passwd = 'admin' User.objects.create_superuser( username=cls.username, password=cls.passwd, email='') cls.candidate = Candidate.objects.all()[0] if not cls.candidate.first_name: cls.candidate.first_name = 'dummy' cls.candidate.save() cls.img_path = op.join(op.dirname(__file__), 'files', 'img.jpg')
def setUp(self): StaticLiveServerTestCase.setUp(self) profile = FirefoxProfile() # Browser itself attempts to validate form fields before they are sent to django. # Fields where input type="Number" accept "100.0" when locale is "en" and "100,0" when locale is "fi", and when # they reject the value, django sees an empty value instead. # To prevent this causing more problems, force browser used by tests to use same locale as django, typically # "en". # We may want to occassionally test with other locales, so localize_input, number_format etc. when entering # and reading decimals/floats. profile.set_preference("intl.accept_languages", get_language()) profile.set_preference("general.useragent.locale", get_language()) self.selenium = Firefox( firefox_profile=profile, executable_path='node_modules/geckodriver/geckodriver') self.selenium.maximize_window()
class Server(object): def __init__(self): self._tc = StaticLiveServerTestCase('__init__') def start_server(self): self._requests_patcher = patch_requests() self._tc.setUpClass() logging.info("Server started: %s", self._tc.live_server_url) BuiltIn().set_suite_variable('${HOST}', self._tc.live_server_url) def stop_server(self): self._tc.tearDownClass() self._requests_patcher.stop() def server_command(self, name, *args, **kwargs): call_command(name, *args, **kwargs)
def setUpClass(cls): WithForm460ADataTest.setUpClass() StaticLiveServerTestCase.setUpClass() cls.username = '******' cls.passwd = 'admin' User.objects.create_superuser(username=cls.username, password=cls.passwd, email='') cls.candidate = Candidate.objects.all()[0] if not cls.candidate.first_name: cls.candidate.first_name = 'dummy' cls.candidate.save() cls.img_path = op.join(op.dirname(__file__), 'files', 'img.jpg')
def run_tests(self, test_labels, extra_tests=None, **kwargs): # Disable logging below CRITICAL during tests. logging.disable(logging.CRITICAL) self.setup_test_environment() self.dbs = self.setup_databases() # Create a static server, it should start immediately. StaticLiveServerTestCase.setUpClass() # Set the environment variables used by Protractor. self.set_env_test_url() self.run_suite() return
def teardown(self): self.teardown_databases(self.dbs) self.teardown_test_environment() StaticLiveServerTestCase.tearDownClass()
def run(self, result=None): self._test_result = result StaticLiveServerTestCase.run(self, result)
def tearDownClass(cls): # somehow this deletes the actual media root! # shutil.rmtree(settings.MEDIA_ROOT) StaticLiveServerTestCase.tearDownClass()
def stop(self, fail=False): LiveServerTestCase.tearDownClass() super(DjangoServer, self).stop() return 0
def setUpClass(cls): StaticLiveServerTestCase.setUpClass() with connection.cursor() as cursor: cursor.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm") cursor.execute("CREATE EXTENSION IF NOT EXISTS fuzzystrmatch")
def __init__(self): self._tc = StaticLiveServerTestCase('__init__')
def setUpClass(cls): StaticLiveServerTestCase.setUpClass() if USE_XVFB: # Start xvfb for Firefox cls.vdisplay = Display(visible=0, size=(1024, 768)) cls.vdisplay.start()
def tearDownClass(cls): if USE_XVFB: cls.vdisplay.stop() StaticLiveServerTestCase.tearDownClass()
def tearDownClass(cls): if cls.server_url == cls.live_server_url: StaticLiveServerTestCase.tearDownClass()
def input_new_item(self, text): input_box = self.browser.find_element_by_id('id_new_item') input_box.send_keys(text) input_box.send_keys(Keys.ENTER) def check_row_in_list_table(self, row_text): table = self.browser.find_element_by_id('id_list_table') rows = table.find_elements_by_tag_name('tr') self.assertIn(row_text, [row.text for row in rows]) def tearDown(self): #self.browser.quit() pass #layuots def test_layout_and_styling(self): self.browser.get(self.live_server_url) self.browser.set_window_size(1024, 768) inputbox = self.browser.find_element_by_id("id_new_item") self.assertAlmostEqual(inputbox.location['x']+inputbox.size['width']/2, 512, delta=10) inputbox.send_keys('testing\n') inputbox = self.browser.find_element_by_id("id_new_item") self.assertAlmostEqual(inputbox.location['x']+inputbox.size['width']/2, 512, delta=10) if __name__ == '__main__': StaticLiveServerTestCase.main()
def tearDown(self): self.selenium.quit() StaticLiveServerTestCase.tearDown(self)
def __init__(self, *args, **kwargs): StaticLiveServerTestCase.__init__(self, *args, **kwargs) self.driver = None
def tearDownClass(cls): if not cls.against_staging: StaticLiveServerTestCase.tearDownClass()
def setUpClass(cls): StaticLiveServerTestCase.setUpClass() cls.server_url = cls.live_server_url
def tearDownClass(cls): StaticLiveServerTestCase.tearDownClass()