forked from projectfluent/python-fluent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
30 lines (27 loc) · 1002 Bytes
/
test_utils.py
File metadata and controls
30 lines (27 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
from .utils import patch_files
from os.path import isdir, isfile, join
class TestFileSimulate(unittest.TestCase):
def test_basic(self):
@patch_files(
{
"the.txt": "The",
"en": {
"one.txt": "One",
"two.txt": "Two",
},
}
)
def patch_me(a, b, root):
self.assertEqual(a, 10)
self.assertEqual(b, "b")
with open(join(root, "the.txt")) as f:
self.assertEqual(f.read(), "The")
with open(join(root, "en", "one.txt")) as f:
self.assertEqual(f.read(), "One")
with open(join(root, "en", "two.txt")) as f:
self.assertEqual(f.read(), "Two")
self.assertTrue(isdir(join(root, "en")))
self.assertFalse(isfile(join(root, "none.txt")))
self.assertFalse(isfile(join(root, "en", "three.txt")))
patch_me(10, "b")