Test Hierarchy object creation across a wide range of input types
This commit is contained in:
parent
4236005541
commit
b57b82c383
@ -1,4 +1,11 @@
|
||||
import doctest
|
||||
import unittest
|
||||
|
||||
from hypothesis import given
|
||||
from hypothesis.strategies import booleans, characters, iterables, one_of, none, text
|
||||
from pathlib import Path
|
||||
from rbackup.hierarchy.hierarchy import Hierarchy
|
||||
from unittest.mock import patch
|
||||
|
||||
# ========== Constants ==========
|
||||
TESTING_MODULE = "rbackup.hierarchy.hierarchy"
|
||||
@ -8,3 +15,15 @@ TESTING_MODULE = "rbackup.hierarchy.hierarchy"
|
||||
def load_tests(loader, tests, ignore):
|
||||
tests.addTests(doctest.DocTestSuite(TESTING_MODULE))
|
||||
return tests
|
||||
|
||||
|
||||
# ========== Tests ==========
|
||||
class TestHierarchyPaths(unittest.TestCase):
|
||||
@given(one_of(text(), characters()))
|
||||
def test_returns_correct_path(self, p):
|
||||
self.assertEqual(Path(p), Hierarchy(p).path)
|
||||
|
||||
@given(one_of(iterables(elements=none()), booleans()))
|
||||
def test_raises_value_error(self, p):
|
||||
with self.assertRaises(TypeError):
|
||||
Hierarchy(p)
|
||||
|
Loading…
x
Reference in New Issue
Block a user