summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozfile/tests/test_tree.py
blob: eba7d34a6b1c1f9ce8099ed0b5b560fb95bf77c2 (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=u"tmp🍪")
            os.mkdir(os.path.join(tmpdir, u"dir🍪"))
            with open(os.path.join(tmpdir, u"file🍪"), "w") as f:
                f.write("foo")

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


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