diff options
| author | Árni Dagur <agudmundsson@fc-md.umd.edu> | 2020-06-21 18:20:20 -0400 |
|---|---|---|
| committer | Árni Dagur <agudmundsson@fc-md.umd.edu> | 2020-06-21 18:20:20 -0400 |
| commit | 019b5b35ebf07022e37d6b8715820b439a18f32b (patch) | |
| tree | 9b4cc5cbe5b50dc9d748ca23a224dc31237ca903 /tests/test_engine.py | |
| parent | 4bb4cb4e6c49226740e80a8dd1639274e0719b53 (diff) | |
Correct return type for the serialize method
Diffstat (limited to 'tests/test_engine.py')
| -rw-r--r-- | tests/test_engine.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_engine.py b/tests/test_engine.py index af15b6d..28e25e6 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | import adblock | 1 | import adblock |
| 2 | import pytest | ||
| 2 | 3 | ||
| 3 | 4 | ||
| 4 | def test_engine_arguments(): | 5 | def test_engine_arguments(): |
| @@ -9,3 +10,31 @@ def test_engine_arguments(): | |||
| 9 | adblock.Engine(network_filters=[]) | 10 | adblock.Engine(network_filters=[]) |
| 10 | adblock.Engine(load_network=False, load_cosmetic=True, debug=False) | 11 | adblock.Engine(load_network=False, load_cosmetic=True, debug=False) |
| 11 | adblock.Engine(debug=True) | 12 | adblock.Engine(debug=True) |
| 13 | |||
| 14 | |||
| 15 | def test_serde_file(tmpdir): | ||
| 16 | path = str(tmpdir / "cache.dat") | ||
| 17 | |||
| 18 | engine0 = adblock.Engine() | ||
| 19 | with pytest.raises(FileNotFoundError): | ||
| 20 | # We haven't created the cache.dat file, so we should get an exception | ||
| 21 | # when attempting to deserialize. | ||
| 22 | engine0.deserialize_from_file(path) | ||
| 23 | |||
| 24 | engine1 = adblock.Engine() | ||
| 25 | serialization_result = engine1.serialize_to_file(path) | ||
| 26 | assert serialization_result is None | ||
| 27 | |||
| 28 | engine2 = adblock.Engine() | ||
| 29 | deserialization_result = engine2.deserialize_from_file(path) | ||
| 30 | assert deserialization_result is None | ||
| 31 | |||
| 32 | |||
| 33 | def test_serde(): | ||
| 34 | engine = adblock.Engine() | ||
| 35 | serialization_result = engine.serialize() | ||
| 36 | assert isinstance(serialization_result, bytes) | ||
| 37 | |||
| 38 | engine2 = adblock.Engine() | ||
| 39 | deserialization_result = engine2.deserialize(serialization_result) | ||
| 40 | assert deserialization_result is None | ||
