1212tmp_dir = tempfile .TemporaryDirectory (f"-pytest-{ time ()} " )
1313tmp_path = Path (tmp_dir .name )
1414test_data_path = (Path (__file__ ) / ".." / "data" ).resolve ().absolute ()
15+ if not test_data_path .exists ():
16+ test_data_path = Path ("./test/test_cli/data" ).resolve ().absolute ()
17+ if not test_data_path .exists ():
18+ test_data_path = None
1519
1620
1721# Create fixture to auto cleanup tmp directory after tests
@@ -24,8 +28,6 @@ def tmp_dir_cleanup():
2428# download GitHub Gist dataset into tmp folder
2529GISTS_URL = "https://api.github.com/gists"
2630gists = requests .get (GISTS_URL ).json ()
27- print (type (gists ))
28- print (gists )
2931for item in gists :
3032 with (tmp_path / f"{ item ['id' ]} .gist" ).open ("w" ) as f :
3133 json .dump (item , f )
@@ -50,16 +52,23 @@ def test_help():
5052 print (stdout .decode ())
5153
5254
55+ if test_data_path :
56+ mark_test_data = {}
57+ else :
58+ mark_test_data = {"mark" : pytest .mark .xfail }
59+
5360test_commands = [
54- pytest .param (f"""{ executable } -l Photo items "{ test_data_path / 'photos.json' } " """ , id = "list1" ),
55- pytest .param (f"""{ executable } -l User - "{ test_data_path / 'users.json' } " """ , id = "list2" ),
56- pytest .param (f"""{ executable } -m Photos "{ test_data_path / 'photos.json' } " """ , id = "model1" ),
61+ pytest .param (f"""{ executable } -l Photo items "{ test_data_path / 'photos.json' } " """ , id = "list1" , ** mark_test_data ),
62+ pytest .param (f"""{ executable } -l User - "{ test_data_path / 'users.json' } " """ , id = "list2" , ** mark_test_data ),
63+ pytest .param (f"""{ executable } -m Photos "{ test_data_path / 'photos.json' } " """ , id = "model1" , ** mark_test_data ),
5764
5865 pytest .param (f"""{ executable } -l Photo items "{ test_data_path / 'photos.json' } "
59- -m Photos "{ test_data_path / 'photos.json' } " """ , id = "list1_model1" ),
66+ -m Photos "{ test_data_path / 'photos.json' } " """ ,
67+ id = "list1_model1" , ** mark_test_data ),
6068
6169 pytest .param (f"""{ executable } -l Photo items "{ test_data_path / 'photos.json' } "
62- -l User - "{ test_data_path / 'users.json' } " """ , id = "list1_list2" ),
70+ -l User - "{ test_data_path / 'users.json' } " """ ,
71+ id = "list1_list2" , ** mark_test_data ),
6372
6473 pytest .param (f"""{ executable } -m Gist "{ tmp_path / '*.gist' } " """ , id = "gists" ),
6574 pytest .param (f"""{ executable } -m Gist "{ tmp_path / '*.gist' } " --datetime""" , id = "gists_datetime" ),
0 commit comments