aboutsummaryrefslogtreecommitdiffstats
path: root/test/fixtures.py
AgeCommit message (Collapse)AuthorFilesLines
2018-11-16test: convert capture tests to use fixtures, fix tests without dumpcapPeter Wu1-5/+38
Add a new --capture-interface option to pytest, similar to test.py. It will grab some Ethernet interface on Windows. An empty value overrides this and disables capture tests. Remove the test.py --enable-capture option since that is implied by the --capture-interface option. Port the `test.py --program-path` option to pytest and additionally make the pytest look in the current working directory if neither WS_BIN_PATH nor --program-path are specified. Drop config.setProgramPath, this allows tests to be run even if not all binaries are available. With all capture tests converted to fixtures, it is now possible to run tests when Wireshark is not built with libpcap as tests that depend on cmd_dumpcap (or capture_interface) will be skipped. Bug: 14949 Change-Id: Ie802c07904936de4cd30a4c68b6a5139e6680fbd Reviewed-on: https://code.wireshark.org/review/30656 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-09test: make it possible to use pytest-style test fixturesPeter Wu1-0/+337
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>