@@ -26,7 +26,7 @@ def inside_dir(dirpath):
26
26
27
27
28
28
@contextmanager
29
- def bake_in_temp_dir (cookies , * args , ** kwargs ):
29
+ def bake_in_temp_dir_and_install (cookies , * args , ** kwargs ):
30
30
"""
31
31
Delete the temporal directory that is created when executing the tests
32
32
:param cookies: pytest_cookies.Cookies,
@@ -35,9 +35,11 @@ def bake_in_temp_dir(cookies, *args, **kwargs):
35
35
result = cookies .bake (* args , ** kwargs )
36
36
37
37
try :
38
+ run_inside_dir ("pip install ./" , str (result .project ))
38
39
yield result
39
40
finally :
40
41
if result .project is not None and os .path .exists (result .project ):
42
+ os .system ("pip uninstall -y " + result .project .basename )
41
43
rmtree (str (result .project ))
42
44
43
45
@@ -58,7 +60,7 @@ def check_output_inside_dir(command, dirpath):
58
60
59
61
60
62
def test_year_compute_in_license_file (cookies ):
61
- with bake_in_temp_dir (cookies ) as result :
63
+ with bake_in_temp_dir_and_install (cookies ) as result :
62
64
license_file_path = result .project .join ("LICENSE" )
63
65
now = datetime .datetime .now ()
64
66
assert str (now .year ) in license_file_path .read ()
@@ -73,7 +75,7 @@ def project_info(result):
73
75
74
76
75
77
def test_bake_with_defaults (cookies ):
76
- with bake_in_temp_dir (cookies ) as result :
78
+ with bake_in_temp_dir_and_install (cookies ) as result :
77
79
assert result .project .isdir ()
78
80
assert result .exit_code == 0
79
81
assert result .exception is None
@@ -86,14 +88,14 @@ def test_bake_with_defaults(cookies):
86
88
87
89
88
90
def test_bake_and_run_tests (cookies ):
89
- with bake_in_temp_dir (cookies ) as result :
91
+ with bake_in_temp_dir_and_install (cookies ) as result :
90
92
assert result .project .isdir ()
91
93
assert run_inside_dir ("pytest" , str (result .project )) == 0
92
94
93
95
94
96
def test_bake_withspecialchars_and_run_tests (cookies ):
95
97
"""Ensure that a `full_name` with double quotes does not break setup.py"""
96
- with bake_in_temp_dir (
98
+ with bake_in_temp_dir_and_install (
97
99
cookies , extra_context = {"full_name" : 'name "quote" name' }
98
100
) as result :
99
101
assert result .project .isdir ()
@@ -102,7 +104,7 @@ def test_bake_withspecialchars_and_run_tests(cookies):
102
104
103
105
def test_bake_with_apostrophe_and_run_tests (cookies ):
104
106
"""Ensure that a `full_name` with apostrophes does not break setup.py"""
105
- with bake_in_temp_dir (cookies , extra_context = {"full_name" : "O'connor" }) as result :
107
+ with bake_in_temp_dir_and_install (cookies , extra_context = {"full_name" : "O'connor" }) as result :
106
108
assert result .project .isdir ()
107
109
assert run_inside_dir ("pytest" , str (result .project )) == 0
108
110
@@ -117,15 +119,15 @@ def test_bake_selecting_license(cookies):
117
119
"GNU General Public License v3" : "GNU GENERAL PUBLIC LICENSE" ,
118
120
}
119
121
for license , target_string in license_strings .items ():
120
- with bake_in_temp_dir (
122
+ with bake_in_temp_dir_and_install (
121
123
cookies , extra_context = {"open_source_license" : license }
122
124
) as result :
123
125
assert target_string in result .project .join ("LICENSE" ).read ()
124
126
assert license in result .project .join ("setup.py" ).read ()
125
127
126
128
127
129
def test_bake_not_open_source (cookies ):
128
- with bake_in_temp_dir (
130
+ with bake_in_temp_dir_and_install (
129
131
cookies , extra_context = {"open_source_license" : "Not open source" }
130
132
) as result :
131
133
found_toplevel_files = [f .basename for f in result .project .listdir ()]
@@ -135,7 +137,7 @@ def test_bake_not_open_source(cookies):
135
137
136
138
137
139
def test_using_pytest (cookies ):
138
- with bake_in_temp_dir (cookies , extra_context = {"use_pytest" : "y" }) as result :
140
+ with bake_in_temp_dir_and_install (cookies , extra_context = {"use_pytest" : "y" }) as result :
139
141
assert result .project .isdir ()
140
142
test_file_path = result .project .join ("tests/test_pysteps_importer_institution_name.py" )
141
143
lines = test_file_path .readlines ()
0 commit comments