6
6
import pytest
7
7
from pony import orm
8
8
from pytask import cli
9
- from pytask import db
10
9
from pytask import ExitCode
11
10
from pytask_environment .database import Environment
12
11
12
+ # Can be removed with pytask v0.4.
13
+ try :
14
+ from pytask import db
15
+ except ImportError :
16
+ from _pytask .database_utils import db
17
+
13
18
14
19
@pytest .mark .end_to_end
15
20
def test_existence_of_python_executable_in_db (tmp_path , runner ):
16
21
"""Test that the Python executable is stored in the database."""
17
22
task_path = tmp_path .joinpath ("task_dummy.py" )
18
23
task_path .write_text (textwrap .dedent ("def task_dummy(): pass" ))
19
- tmp_path .joinpath ("pytask.ini " ).write_text ("[pytask]" )
24
+ tmp_path .joinpath ("pyproject.toml " ).write_text ("[tool. pytask.ini_options ]" )
20
25
21
26
result = runner .invoke (cli , [tmp_path .as_posix ()])
22
27
@@ -34,13 +39,7 @@ def test_existence_of_python_executable_in_db(tmp_path, runner):
34
39
35
40
36
41
@pytest .mark .end_to_end
37
- @pytest .mark .parametrize (
38
- "config_file, content" ,
39
- [("pytask.ini" , "[pytask]" ), ("pyproject.toml" , "[tool.pytask.ini_options]" )],
40
- )
41
- def test_flow_when_python_version_has_changed (
42
- monkeypatch , tmp_path , runner , config_file , content
43
- ):
42
+ def test_flow_when_python_version_has_changed (monkeypatch , tmp_path , runner ):
44
43
"""Test the whole use-case.
45
44
46
45
1. Run a simple task to cache the Python version and path.
@@ -57,7 +56,7 @@ def test_flow_when_python_version_has_changed(
57
56
"[MSC v.1916 64 bit (AMD64)]"
58
57
)
59
58
60
- tmp_path .joinpath (config_file ).write_text (content )
59
+ tmp_path .joinpath ("pyproject.toml" ).write_text ("[tool.pytask.ini_options]" )
61
60
source = "def task_dummy(): pass"
62
61
task_path = tmp_path .joinpath ("task_dummy.py" )
63
62
task_path .write_text (textwrap .dedent (source ))
@@ -98,22 +97,17 @@ def test_flow_when_python_version_has_changed(
98
97
99
98
100
99
@pytest .mark .end_to_end
101
- @pytest .mark .parametrize (
102
- "config_file, content" ,
103
- [
104
- ("pytask.ini" , "[pytask]\n check_python_version = {}" ),
105
- ("pyproject.toml" , "[tool.pytask.ini_options]\n check_python_version = {}" ),
106
- ],
107
- )
108
100
@pytest .mark .parametrize ("check_python_version, expected" , [("true" , 1 ), ("false" , 0 )])
109
101
def test_python_version_changed (
110
- monkeypatch , tmp_path , runner , config_file , content , check_python_version , expected
102
+ monkeypatch , tmp_path , runner , check_python_version , expected
111
103
):
112
104
fake_version = (
113
105
"2.7.8 | packaged by conda-forge | (default, Jul 31 2020, 01:53:57) "
114
106
"[MSC v.1916 64 bit (AMD64)]"
115
107
)
116
- tmp_path .joinpath (config_file ).write_text (content .format (check_python_version ))
108
+ tmp_path .joinpath ("pyproject.toml" ).write_text (
109
+ f"[tool.pytask.ini_options]\n check_python_version = { check_python_version } "
110
+ )
117
111
source = "def task_dummy(): pass"
118
112
task_path = tmp_path .joinpath ("task_dummy.py" )
119
113
task_path .write_text (textwrap .dedent (source ))
@@ -136,18 +130,13 @@ def test_python_version_changed(
136
130
137
131
138
132
@pytest .mark .end_to_end
139
- @pytest .mark .parametrize (
140
- "config_file, content" ,
141
- [
142
- ("pytask.ini" , "[pytask]\n check_environment = {}" ),
143
- ("pyproject.toml" , "[tool.pytask.ini_options]\n check_environment = {}" ),
144
- ],
145
- )
146
133
@pytest .mark .parametrize ("check_python_version, expected" , [("true" , 1 ), ("false" , 0 )])
147
134
def test_environment_changed (
148
- monkeypatch , tmp_path , runner , config_file , content , check_python_version , expected
135
+ monkeypatch , tmp_path , runner , check_python_version , expected
149
136
):
150
- tmp_path .joinpath (config_file ).write_text (content .format (check_python_version ))
137
+ tmp_path .joinpath ("pyproject.toml" ).write_text (
138
+ f"[tool.pytask.ini_options]\n check_environment = { check_python_version } "
139
+ )
151
140
source = "def task_dummy(): pass"
152
141
task_path = tmp_path .joinpath ("task_dummy.py" )
153
142
task_path .write_text (textwrap .dedent (source ))
0 commit comments