summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozfile/tests/test_tree.py
blob: 556c1b91391bf88e6d8f2688e74bc019e25204b4 (plain)
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
#!/usr/bin/env python
# coding=UTF-8

import os
import shutil
import tempfile
import unittest

import mozunit
from mozfile import tree


class TestTree(unittest.TestCase):
    """Test the tree function."""

    def test_unicode_paths(self):
        """Test creating tree structure from a Unicode path."""
        try:
            tmpdir = tempfile.mkdtemp(suffix="tmp🍪")
            os.mkdir(os.path.join(tmpdir, "dir🍪"))
            with open(os.path.join(tmpdir, "file🍪"), "w") as f:
                f.write("foo")

            self.assertEqual("{}\n├file🍪\n└dir🍪".format(tmpdir), tree(tmpdir))
        finally:
            shutil.rmtree(tmpdir)


if __name__ == "__main__":
    mozunit.main()