Debian Codegraph @

testing/mozbase/mozfile/tests/test_tree.py

raw
1 #!/usr/bin/env python
2 # coding=UTF-8
3
4 import os
5 import shutil
6 import tempfile
7 import unittest
8
9 import mozunit
10 from mozfile import tree
11
12
13 class TestTree(unittest.TestCase):
14 """Test the tree function."""
15
16 def test_unicode_paths(self):
17 """Test creating tree structure from a Unicode path."""
18 try:
19 tmpdir = tempfile.mkdtemp(suffix="tmp🍪")
20 os.mkdir(os.path.join(tmpdir, "dir🍪"))
21 with open(os.path.join(tmpdir, "file🍪"), "w") as f:
22 f.write("foo")
23
24 self.assertEqual(f"{tmpdir}\n├file🍪\n└dir🍪", tree(tmpdir))
25 finally:
26 shutil.rmtree(tmpdir)
27
28
29 if __name__ == "__main__":
30 mozunit.main()