Skip to content

Commit ad01248

Browse files
author
Chris Patterson
authored
tests: add missing asserts to python unit tests (#3206)
Fix broken tests that fell out of date after the removal of virtual environment `activate` usage. Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
1 parent 1086056 commit ad01248

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

tests/unit/plugins/v2/test_python.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ def test_schema():
5151
def test_get_build_packages():
5252
plugin = PythonPlugin(part_name="my-part", options=lambda: None)
5353

54-
plugin.get_build_packages() == {"findutils", "python3-venv", "python3-dev"}
54+
assert plugin.get_build_packages() == {"findutils", "python3-venv", "python3-dev"}
5555

5656

5757
def test_get_build_environment():
5858
plugin = PythonPlugin(part_name="my-part", options=lambda: None)
5959

60-
plugin.get_build_environment() == {
60+
assert plugin.get_build_environment() == {
6161
"PATH": "${SNAPCRAFT_PART_INSTALL}/bin:${PATH}",
6262
"SNAPCRAFT_PYTHON_INTERPRETER": "python3",
6363
"SNAPCRAFT_PYTHON_VENV_ARGS": "",
@@ -105,12 +105,15 @@ class Options:
105105

106106
plugin = PythonPlugin(part_name="my-part", options=Options())
107107

108-
plugin.get_build_commands() == [
109-
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
110-
'"${SNAPCRAFT_PART_INSTALL}"',
111-
'. "${SNAPCRAFT_PART_INSTALL}/bin/activate"',
112-
"[ -f setup.py ] && pip install -U .",
113-
] + _FIXUP_BUILD_COMMANDS
108+
assert (
109+
plugin.get_build_commands()
110+
== [
111+
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
112+
'"${SNAPCRAFT_PART_INSTALL}"',
113+
"[ -f setup.py ] && pip install -U .",
114+
]
115+
+ _FIXUP_BUILD_COMMANDS
116+
)
114117

115118

116119
def test_get_build_commands_with_all_properties():
@@ -121,11 +124,14 @@ class Options:
121124

122125
plugin = PythonPlugin(part_name="my-part", options=Options())
123126

124-
plugin.get_build_commands() == [
125-
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
126-
'"${SNAPCRAFT_PART_INSTALL}"',
127-
'. "${SNAPCRAFT_PART_INSTALL}/bin/activate"',
128-
"pip install -c 'constraints.txt' -U pip",
129-
"pip install -c 'constraints.txt' -U -r 'requirements.txt'",
130-
"[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
131-
] + _FIXUP_BUILD_COMMANDS
127+
assert (
128+
plugin.get_build_commands()
129+
== [
130+
'"${SNAPCRAFT_PYTHON_INTERPRETER}" -m venv ${SNAPCRAFT_PYTHON_VENV_ARGS} '
131+
'"${SNAPCRAFT_PART_INSTALL}"',
132+
"pip install -c 'constraints.txt' -U pip",
133+
"pip install -c 'constraints.txt' -U -r 'requirements.txt'",
134+
"[ -f setup.py ] && pip install -c 'constraints.txt' -U .",
135+
]
136+
+ _FIXUP_BUILD_COMMANDS
137+
)

0 commit comments

Comments
 (0)