From b57b82c383c15741d36f66dc7eb5240c653929e5 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Thu, 28 Mar 2019 12:09:09 -0700 Subject: [PATCH] Test Hierarchy object creation across a wide range of input types --- rbackup/tests/test_hierarchy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rbackup/tests/test_hierarchy.py b/rbackup/tests/test_hierarchy.py index 45dc537..bf11ff4 100644 --- a/rbackup/tests/test_hierarchy.py +++ b/rbackup/tests/test_hierarchy.py @@ -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)