Exemplo n.º 1
0
 def test_unix_path_hierarchy(self):
     """Main case where we build a hierarchy of paths"""
     actual = vega.build_hierarchy(self.input_df['path'].
                                   str.replace(r'\\', '/').
                                   str.replace(r'^\./', '').
                                   to_frame('path'),
                                   root='')
     expected = pd.read_csv(io.StringIO(textwrap.dedent(r'''
     id,parent,path
     0,,
     1,0,doc
     2,0,pandas
     3,1,doc/source
     4,2,pandas/io
     5,2,pandas/tests
     6,5,pandas/tests/io
     7,3,doc/source/_static
     8,6,pandas/tests/io/data
     9,4,pandas/io/pytables.py
     10,5,pandas/tests/test_window.py
     11,6,pandas/tests/io/test_pytables.py
     12,7,doc/source/_static/banklist.html
     13,8,pandas/tests/io/data/banklist.html''')),
                            dtype={'id': 'int64', 'parent': 'float',
                                   'path': 'object'})
     expected.loc[expected['path'].isnull(), 'path'] = ''
     self.assertEqual(expected, actual)
Exemplo n.º 2
0
 def test_unix_path_hierarchy(self):
     """Main case where we build a hierarchy of paths"""
     actual = vega.build_hierarchy(
         self.input_df["path"].str.replace(r"\\", "/").str.replace(
             r"^\./", "").to_frame("path"),
         root="",
     )
     expected = pd.read_csv(
         io.StringIO(
             textwrap.dedent(r"""
     id,parent,path
     0,,
     1,0,doc
     2,0,pandas
     3,1,doc/source
     4,2,pandas/io
     5,2,pandas/tests
     6,5,pandas/tests/io
     7,3,doc/source/_static
     8,6,pandas/tests/io/data
     9,4,pandas/io/pytables.py
     10,5,pandas/tests/test_window.py
     11,6,pandas/tests/io/test_pytables.py
     12,7,doc/source/_static/banklist.html
     13,8,pandas/tests/io/data/banklist.html""")),
         dtype={
             "id": "int64",
             "parent": "float",
             "path": "object"
         },
     )
     expected.loc[expected["path"].isnull(), "path"] = ""
     self.assertEqual(expected, actual)
Exemplo n.º 3
0
 def test_path_hierarchy(self):
     """Main case where we build a hierarchy of paths"""
     actual = vega.build_hierarchy(self.input_df[["path"]])
     expected = pd.read_csv(
         io.StringIO(
             textwrap.dedent(r"""
     id,parent,path
     0,,
     1,0,doc
     2,0,pandas
     3,1,doc\source
     4,2,pandas\io
     5,2,pandas\tests
     6,5,pandas\tests\io
     7,3,doc\source\_static
     8,6,pandas\tests\io\data
     9,4,pandas\io\pytables.py
     10,5,pandas\tests\test_window.py
     11,6,pandas\tests\io\test_pytables.py
     12,7,doc\source\_static\banklist.html
     13,8,pandas\tests\io\data\banklist.html""")),
         dtype={
             "id": "int64",
             "parent": "float",
             "path": "object"
         },
     )
     expected.loc[expected["path"].isnull(), "path"] = ""
     self.assertEqual(expected, actual)
Exemplo n.º 4
0
 def test_path_hierarchy(self):
     """Main case where we build a hierarchy of paths"""
     actual = vega.build_hierarchy(self.input_df[['path']])
     expected = pd.read_csv(io.StringIO(textwrap.dedent(r'''
     id,parent,path
     0,,
     1,0,doc
     2,0,pandas
     3,1,doc\source
     4,2,pandas\io
     5,2,pandas\tests
     6,5,pandas\tests\io
     7,3,doc\source\_static
     8,6,pandas\tests\io\data
     9,4,pandas\io\pytables.py
     10,5,pandas\tests\test_window.py
     11,6,pandas\tests\io\test_pytables.py
     12,7,doc\source\_static\banklist.html
     13,8,pandas\tests\io\data\banklist.html''')),
                            dtype={'id': 'int64', 'parent': 'float',
                                   'path': 'object'})
     expected.loc[expected['path'].isnull(), 'path'] = ''
     self.assertEqual(expected, actual)
Exemplo n.º 5
0
 def test_root_not_found(self):
     """Get a decent diagnostic when the root is not found."""
     with self.assertRaises(ValueError) as context:
         vega.build_hierarchy(self.input_df, root='X')
     self.assertIn('cannot find root', str(context.exception))
Exemplo n.º 6
0
 def test_input_does_not_change(self):
     """Make sure the input does not get modified."""
     backup = self.input_df.copy()
     _ = vega.build_hierarchy(self.input_df)
     self.assertEqual(self.input_df, backup)