Advertisement
zolmoz

Untitled

Sep 24th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.84 KB | None | 0 0
  1. fixture = None
  2. target = None
  3.  
  4. def load_config(file):
  5.     global target
  6.     if target is None:
  7.         config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
  8.         with open(config_file) as f:
  9.             target = json.load(f)
  10.     return target
  11.  
  12.  
  13. @pytest.fixture
  14. def app(request):
  15.     global fixture
  16.     browser = request.config.getoption("--browser")
  17.     web_config = load_config(request.config.getoption("--target"))['web']
  18.     if fixture is None or not fixture.is_valid():
  19.         fixture = Application(browser=browser, base_url=web_config['baseURL'])
  20.     fixture.session.ensure_login(user_name=web_config['user_name'], password=web_config['password'])
  21.     return fixture
  22.  
  23. @pytest.fixture (scope="session")
  24. def db(request):
  25.     db_config = load_config(request.config.getoption("--target"))['db']
  26.     dbfixture = Dbfixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])
  27.     def fin():
  28.         dbfixture.destroy()
  29.     request.addfinalizer(fin)
  30.     return dbfixture
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. E
  40. test setup failed
  41. request = <SubRequest 'app' for <Function 'test_test_ad_group[None:::]'>>
  42.  
  43.     @pytest.fixture
  44.     def app(request):
  45.         global fixture
  46.         browser = request.config.getoption("--browser")
  47. >       web_config = load_config(request.config.getoption("--target"))['web']
  48.  
  49. ..\conftest.py:25:
  50. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  51. ..\conftest.py:17: in load_config
  52.     target = json.load(f)
  53. c:\python37\Lib\json\__init__.py:296: in load
  54.     parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  55. c:\python37\Lib\json\__init__.py:348: in loads
  56.     return _default_decoder.decode(s)
  57. c:\python37\Lib\json\decoder.py:337: in decode
  58.     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  59. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  60.  
  61. self = <json.decoder.JSONDecoder object at 0x027EEED0>
  62. s = '{\n  web:{\n    "baseURL": "http://localhost/addressbook/",\n    "user_name": "admin",\n    "password": "secret"\n  },\n  "db":{\n    "host": "localhost",\n    "name": "addressbook",\n    "user": "root",\n    "password": ""\n  }\n}'
  63. idx = 0
  64.  
  65.     def raw_decode(self, s, idx=0):
  66.         """Decode a JSON document from ``s`` (a ``str`` beginning with
  67.            a JSON document) and return a 2-tuple of the Python
  68.            representation and the index in ``s`` where the document ended.
  69.    
  70.            This can be used to decode a JSON document from a string that may
  71.            have extraneous data at the end.
  72.    
  73.            """
  74.         try:
  75. >           obj, end = self.scan_once(s, idx)
  76. E           json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)
  77.  
  78. c:\python37\Lib\json\decoder.py:353: JSONDecodeError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement