本文整理汇总了Python中django.test.LiveServerTestCase类的典型用法代码示例。如果您正苦于以下问题:Python LiveServerTestCase类的具体用法?Python LiveServerTestCase怎么用?Python LiveServerTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LiveServerTestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
def setUpClass(cls):
for arg in sys.argv:
if "liveserver" in arg:
cls.server_url = "http://" + arg.split("=")[1]
return
LiveServerTestCase.setUpClass()
cls.server_url = cls.live_server_url
示例2: setUpClass
def setUpClass(cls):
for arg in sys.argv:
if 'liveserver' in arg:
cls.server_url = "http://" + arg.split("=")[1]
return
LiveServerTestCase.setUpClass()
#cls.server_url = cls.live_server_url
cls.server_url = "http://127.0.0.1:8081/"
示例3: setUpClass
def setUpClass(cls):
for arg in sys.argv:
if 'liveserver' in arg:
cls.server_url = 'http://' + arg.split('=')[1]
fixtures = [] #no fixtures for testing liveserver staging
return
LiveServerTestCase.setUpClass()
cls.server_url = cls.live_server_url
示例4: tearDown
def tearDown(self):
from django.conf import settings
for searcher in get_available_search_engines():
searcher.clear_cache()
shutil.rmtree(settings.WIRECLOUD_INDEX_DIR, ignore_errors=True)
LiveServerTestCase.tearDown(self)
示例5: setUp
def setUp(self):
LiveServerTestCase.setUp(self)
from selenium import webdriver
mobile_emulation = {
#"deviceName": "Apple iPhone 3GS"
#"deviceName": "Apple iPhone 4"
"deviceName": "Apple iPhone 5"
#"deviceName": "Apple iPhone 6"
#"deviceName": "Apple iPhone 6 Plus"
#"deviceName": "BlackBerry Z10"
#"deviceName": "BlackBerry Z30"
#"deviceName": "Google Nexus 4"
#"deviceName": "Google Nexus 5"
#"deviceName": "Google Nexus S"
#"deviceName": "HTC Evo, Touch HD, Desire HD, Desire"
#"deviceName": "HTC One X, EVO LTE"
#"deviceName": "HTC Sensation, Evo 3D"
#"deviceName": "LG Optimus 2X, Optimus 3D, Optimus Black"
#"deviceName": "LG Optimus G"
#"deviceName": "LG Optimus LTE, Optimus 4X HD"
#"deviceName": "LG Optimus One"
#"deviceName": "Motorola Defy, Droid, Droid X, Milestone"
#"deviceName": "Motorola Droid 3, Droid 4, Droid Razr, Atrix 4G, Atrix 2"
#"deviceName": "Motorola Droid Razr HD"
#"deviceName": "Nokia C5, C6, C7, N97, N8, X7"
#"deviceName": "Nokia Lumia 7X0, Lumia 8XX, Lumia 900, N800, N810, N900"
#"deviceName": "Samsung Galaxy Note 3"
#"deviceName": "Samsung Galaxy Note II"
#"deviceName": "Samsung Galaxy Note"
#"deviceName": "Samsung Galaxy S III, Galaxy Nexus"
#"deviceName": "Samsung Galaxy S, S II, W"
#"deviceName": "Samsung Galaxy S4"
#"deviceName": "Sony Xperia S, Ion"
#"deviceName": "Sony Xperia Sola, U"
#"deviceName": "Sony Xperia Z, Z1"
#"deviceName": "Amazon Kindle Fire HDX 7″"
#"deviceName": "Amazon Kindle Fire HDX 8.9″"
#"deviceName": "Amazon Kindle Fire (First Generation)"
#"deviceName": "Apple iPad 1 / 2 / iPad Mini"
#"deviceName": "Apple iPad 3 / 4"
#"deviceName": "BlackBerry PlayBook"
#"deviceName": "Google Nexus 10"
#"deviceName": "Google Nexus 7 2"
#"deviceName": "Google Nexus 7"
#"deviceName": "Motorola Xoom, Xyboard"
#"deviceName": "Samsung Galaxy Tab 7.7, 8.9, 10.1"
#"deviceName": "Samsung Galaxy Tab"
#"deviceName": "Notebook with touch"
# Or specify a specific build using the following two arguments
#"deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
#"userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" }
}
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
self.browser = webdriver.Chrome(chrome_options=chrome_options)
示例6: setUpClass
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
LiveServerTestCase.setUpClass()
cls.against_staging = False
cls.server_url = cls.live_server_url
示例7: setUpClass
def setUpClass(cls):
"""
this methos allow run test using:
manage.py test functional_tests --liveserver=my-staging-server.com
"""
for arg in sys.argv:
if 'liveserver' in arg:
cls.server_url = 'http://' + arg.split('=')[1]
return
LiveServerTestCase.setUpClass()
cls.server_url = cls.live_server_url
示例8: __init__
def __init__(self, *args, **kwargs):
dirs = os.listdir(tests_dir)
test_numbers = []
for dir in dirs:
try:
test_number = int(dir)
test_numbers.append(test_number)
except:
pass
self.test_dir = tests_dir + '/{}'.format(len(test_numbers))
os.makedirs(self.test_dir)
self.log_filepath = self.test_dir + '/{}'.format(self.log_filename)
self.error_log_filepath = self.test_dir + '/{}'.format(self.error_log_filename)
LiveServerTestCase.__init__(self, *args, **kwargs)
示例9: tearDown
def tearDown(self):
from django.conf import settings
if self.clear_search_indexes:
management.call_command('clear_index', interactive=False, verbosity=0)
# Reload the connection
haystack.connections.connections_info = settings.HAYSTACK_CONNECTIONS
haystack.connections.reload('default')
time.sleep(0.2)
LiveServerTestCase.tearDown(self)
WirecloudRemoteTestCase.tearDown(self)
示例10: setUp
def setUp(self):
from django.core.cache import cache
restoretree(self.localcatalogue_tmp_dir_backup, self.localcatalogue_tmp_dir)
restoretree(self.catalogue_tmp_dir_backup, self.catalogue_tmp_dir)
cache.clear()
try:
self.network._servers['http']['example.com'].clear()
except:
pass
LiveServerTestCase.setUp(self)
WirecloudRemoteTestCase.setUp(self)
示例11: setUpClass
def setUpClass(cls):
cls.display = None
try:
display = Display(visible=0, size=(1024, 768))
display.start()
except:
pass
for arg in sys.argv:
if 'liveserver' in arg:
cls.server_url = 'http://' + arg.split('=')[1]
return
cls.browser = webdriver.Firefox()
cls.browser.implicitly_wait(5)
LiveServerTestCase.setUpClass()
cls.server_url = cls.live_server_url
示例12: start_liveserver_if_needed
def start_liveserver_if_needed(cls):
cls.liveserver_url = None
for api_cls in cls.get_test_api_classes():
if not getattr(api_cls, 'needs_live_server', False):
continue
if cls.liveserver_url is None:
LiveServerTestCase.setUpClass()
cls.selenium = WebDriver()
# inlined from LiveServerTestCase
cls.liveserver_url = 'http://%s:%s' % (
LiveServerTestCase.server_thread.host, LiveServerTestCase.server_thread.port)
api_cls.server_thread = LiveServerTestCase.server_thread
api_cls.selenium = cls.selenium
api_cls.liveserver_url = cls.liveserver_url
cls.has_liveserver = cls.liveserver_url is not None
示例13: setUp
def setUp(self):
haystack.connections.reload('default')
management.call_command('rebuild_index', interactive=False, verbosity=0)
from django.core.cache import cache
restoretree(self.localcatalogue_tmp_dir_backup, self.localcatalogue_tmp_dir)
restoretree(self.catalogue_tmp_dir_backup, self.catalogue_tmp_dir)
cache.clear()
try:
self.network._servers['http']['example.com'].clear()
except:
pass
LiveServerTestCase.setUp(self)
WirecloudRemoteTestCase.setUp(self)
management.call_command('populate', verbosity=0, interactive=False)
示例14: tearDownClass
def tearDownClass(cls):
""" Cleanup global test/live test environment """
if cls.server_url == cls.live_server_url:
LiveServerTestCase.tearDownClass()
示例15: tearDownClass
def tearDownClass(cls):
if cls.server_url == cls.live_server_url:
LiveServerTestCase.tearDownClass()