Show More
@@ -0,0 +1,31 b'' | |||
|
1 | from unittest import TestCase | |
|
2 | ||
|
3 | from IPython.utils.py3compat import unicode_type | |
|
4 | from .. import parse_filename | |
|
5 | ||
|
6 | ||
|
7 | class MiscTests(TestCase): | |
|
8 | ||
|
9 | def check_filename(self, path, exp_fname, exp_bname, exp_format): | |
|
10 | fname, bname, format = parse_filename(path) | |
|
11 | self.assertEqual(fname, exp_fname) | |
|
12 | self.assertEqual(bname, exp_bname) | |
|
13 | self.assertEqual(format, exp_format) | |
|
14 | ||
|
15 | def test_parse_filename(self): | |
|
16 | ||
|
17 | # check format detection | |
|
18 | self.check_filename("test.ipynb", "test.ipynb", "test", "json") | |
|
19 | self.check_filename("test.json", "test.json", "test", "json") | |
|
20 | self.check_filename("test.py", "test.py", "test", "py") | |
|
21 | ||
|
22 | # check parsing an unknown format | |
|
23 | self.check_filename("test.nb", "test.nb.ipynb", "test.nb", "json") | |
|
24 | ||
|
25 | # check parsing a full file path | |
|
26 | self.check_filename("/tmp/test.ipynb", "/tmp/test.ipynb", "/tmp/test", | |
|
27 | "json") | |
|
28 | ||
|
29 | # check parsing a file name containing dots | |
|
30 | self.check_filename("test.nb.ipynb", "test.nb.ipynb", "test.nb", | |
|
31 | "json") |
General Comments 0
You need to be logged in to leave comments.
Login now