44import time
55import watchdog .events
66from pathlib import Path , PurePath
7- from typing import Callable , List , Tuple , Type
7+ from typing import List , Tuple
88from . import util
99
1010
11- def expect_exception (f : Callable [[], None ], exception_ty : Type [Exception ]) -> None :
12- """Assert that the given function f raises the given exception type."""
13- try :
14- f ()
15- except exception_ty :
16- return
17- except Exception as err :
18- raise AssertionError (f"Expected { exception_ty .__name__ } ; got { err } " )
19-
20- raise AssertionError (f"Expected { exception_ty .__name__ } to be raised" )
21-
22-
2311def test_reroot_path () -> None :
2412 relative , absolute = util .reroot_path (
2513 PurePath ("/foo/bar/baz.rst" ), PurePath ("/foo/dir/test.txt" ), Path ("foo" )
@@ -31,6 +19,34 @@ def test_reroot_path() -> None:
3119 )[0 ] == PurePath ("foo/bar/baz.rst" )
3220
3321
22+ def test_option_string () -> None :
23+ assert util .option_string ("Test" ) == "Test"
24+ # No input or blank input should raise a ValueError
25+ try :
26+ util .option_string (" " )
27+ except ValueError :
28+ pass
29+
30+
31+ def test_option_bool () -> None :
32+ assert util .option_bool ("tRuE" ) == True
33+ assert util .option_bool ("FaLsE" ) == False
34+ # No input or blank input should raise a ValueError
35+ try :
36+ util .option_bool (" " )
37+ except ValueError :
38+ pass
39+
40+
41+ def test_option_flag () -> None :
42+ assert util .option_flag ("" ) == True
43+ # Specifying an argument should raise a ValueError
44+ try :
45+ util .option_flag ("test" )
46+ except ValueError :
47+ pass
48+
49+
3450def test_get_files () -> None :
3551 assert set (util .get_files (PurePath ("test_data" ), (".toml" ,))) == {
3652 Path ("test_data/snooty.toml" ),
0 commit comments