|
22 | 22 |
|
23 | 23 | from diffpy.structure.tests.testutils import datafile |
24 | 24 | from diffpy.structure.parsers.p_cif import P_cif, leading_float, getSymOp |
| 25 | +from diffpy.structure.parsers.p_cif import _quoteLocalPath |
25 | 26 | from diffpy.structure.parsers import getParser |
26 | 27 | from diffpy.structure import Structure |
27 | 28 | from diffpy.structure import StructureFormatError |
@@ -60,6 +61,18 @@ def test_getSymOp(self): |
60 | 61 | self.assertEqual(str(op1_std), str(op1)) |
61 | 62 | return |
62 | 63 |
|
| 64 | + |
| 65 | + def test__quoteLocalPath(self): |
| 66 | + "check _quoteLocalPath()" |
| 67 | + from six.moves.urllib.request import pathname2url as p2u |
| 68 | + self.assertEqual('/a/b/c.cif', _quoteLocalPath('/a/b/c.cif')) |
| 69 | + self.assertEqual(p2u('c:\\a.cif'), _quoteLocalPath('c:\\a.cif')) |
| 70 | + self.assertEqual(p2u('c:/a.cif'), _quoteLocalPath('c:/a.cif')) |
| 71 | + self.assertEqual('/x:y/c.cif', _quoteLocalPath('/x:y/c.cif')) |
| 72 | + self.assertEqual('http::cif.org/a.cif', |
| 73 | + _quoteLocalPath('http::cif.org/a.cif')) |
| 74 | + return |
| 75 | + |
63 | 76 | # End of class TestRoutines |
64 | 77 |
|
65 | 78 | # ---------------------------------------------------------------------------- |
@@ -157,7 +170,11 @@ def test_parseFile(self): |
157 | 170 | self.assertEqual(str, type(c1.label)) |
158 | 171 | self.assertEqual('C1', c1.label) |
159 | 172 | # filename with unicode encoding |
160 | | - ugraphite = P_cif().parseFile(six.u(self.graphiteciffile)) |
| 173 | + hasbs = '\\' in self.graphiteciffile |
| 174 | + uciffile = six.u(self.graphiteciffile.replace('\\', '/')) |
| 175 | + if hasbs: # pragma: no cover |
| 176 | + uciffile = uciffile.replace(u'/', u'\\') |
| 177 | + ugraphite = P_cif().parseFile(uciffile) |
161 | 178 | self.assertEqual(4, len(ugraphite)) |
162 | 179 | # File with full space group name |
163 | 180 | ptei = P_cif().parseFile(self.teiciffile) |
|
0 commit comments