aboutsummaryrefslogtreecommitdiffstats
path: root/test/conftest.py
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-10-15 16:07:30 +0200
committerAnders Broman <a.broman58@gmail.com>2018-11-09 05:03:12 +0000
commit54d7e96a72e5871792b1e0c1c29f6fd1ac0743c0 (patch)
tree9bda71e94c6876367e5ec0e51bf6413848a2be75 /test/conftest.py
parente0ac9133008e02034ed064b7add0d82d4b238d67 (diff)
test: make it possible to use pytest-style test fixtures
Currently all binaries must be available or no tests will be executed. This is inconvenient if you just want to test a single binary (e.g. text2pcap) without having to build epan. The problem is essentially that tests lack dependency annotations. To solve this problem, add the required dependencies as parameters to each test (so-called 'fixtures' in pytest). Skip a test if a binary (such as tshark) is unavailable. As a demonstration, suite_dissection.py is converted. Over time, tests should no longer depend on config.py due to explicit dependencies fixtures (listed in fixtures_ws.py). Since the unittest module does not support such dependency injections, create a small glue for use with pytest and an (incomplete) emulation layer for use with test.py. Tested with pytest 3.8.2 + Python 3.7.0 and pytest 3.0.3 + Python 3.4.3. Python 2.7 is not supported and will fail. Test commands: ~/wireshark/test/test.py -p ~/build/run WS_BIN_PATH=~/build/run pytest ~/wireshark/test -ra Change-Id: I6dc8c28f5c8b7bbc8f4c04838e9bf085cd22eb0b Ping-Bug: 14949 Reviewed-on: https://code.wireshark.org/review/30220 Tested-by: Petri Dish Buildbot Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test/conftest.py')
-rw-r--r--test/conftest.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/conftest.py b/test/conftest.py
index eff63dadaa..a09e86c485 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -10,9 +10,9 @@
import os
import sys
+import fixtures
import config
-
# XXX remove globals in config and create py.test-specific fixtures
try:
_program_path = os.environ['WS_BIN_PATH']
@@ -32,3 +32,7 @@ def pytest_collection_modifyitems(items):
if name not in suites:
suites.append(name)
config.all_groups = list(sorted(suites))
+
+# Must enable pytest before importing fixtures_ws.
+fixtures.enable_pytest()
+from fixtures_ws import *