sqlalchemy_utils.path.Path

Here are the examples of the python api sqlalchemy_utils.path.Path taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

14 Examples 7

Example 1

Project: sqlalchemy-utils Source File: test_path.py
Function: test_len
    @pytest.mark.parametrize(('path', 'length'), (
        (Path('s.s2.s3'), 3),
        (Path('s.s2'), 2),
        (Path(''), 0)
    ))
    def test_len(self, path, length):
        return len(path) == length

Example 2

Project: sqlalchemy-utils Source File: test_path.py
Function: test_eq
    @pytest.mark.parametrize(('test', 'result'), (
        (Path('s.s2') == Path('s.s2'), True),
        (Path('s.s2') == Path('s.s3'), False)
    ))
    def test_eq(self, test, result):
        assert test is result

Example 3

Project: sqlalchemy-utils Source File: test_path.py
Function: test_ne
    @pytest.mark.parametrize(('test', 'result'), (
        (Path('s.s2') != Path('s.s2'), False),
        (Path('s.s2') != Path('s.s3'), True)
    ))
    def test_ne(self, test, result):
        assert test is result

Example 4

Project: sqlalchemy-utils Source File: test_path.py
Function: test_init
    def test_init(self, SubSection):
        path = AttrPath(SubSection, 'section.docuement')
        assert path.class_ == SubSection
        assert path.path == Path('section.docuement')

Example 5

Project: sqlalchemy-utils Source File: test_path.py
Function: test_init
    def test_init(self):
        path = Path('attr.attr2')
        assert path.path == 'attr.attr2'

Example 6

Project: sqlalchemy-utils Source File: test_path.py
    def test_init_with_path_object(self):
        path = Path(Path('attr.attr2'))
        assert path.path == 'attr.attr2'

Example 7

Project: sqlalchemy-utils Source File: test_path.py
Function: test_iter
    def test_iter(self):
        path = Path('s.s2.s3')
        assert list(path) == ['s', 's2', 's3']

Example 8

Project: sqlalchemy-utils Source File: test_path.py
Function: test_reversed
    def test_reversed(self):
        path = Path('s.s2.s3')
        assert list(reversed(path)) == ['s3', 's2', 's']

Example 9

Project: sqlalchemy-utils Source File: test_path.py
Function: test_repr
    def test_repr(self):
        path = Path('s.s2')
        assert repr(path) == "Path('s.s2')"

Example 10

Project: sqlalchemy-utils Source File: test_path.py
Function: test_get_item
    def test_getitem(self):
        path = Path('s.s2')
        assert path[0] == 's'
        assert path[1] == 's2'

Example 11

Project: sqlalchemy-utils Source File: test_path.py
Function: test_str
    def test_str(self):
        assert str(Path('s.s2')) == 's.s2'

Example 12

Project: sqlalchemy-utils Source File: test_path.py
Function: test_index
    def test_index(self):
        assert Path('s.s2.s3').index('s2') == 1

Example 13

Project: sqlalchemy-utils Source File: test_path.py
Function: test_unicode
    def test_unicode(self):
        assert six.text_type(Path('s.s2')) == u's.s2'

Example 14

Project: sqlalchemy-utils Source File: test_path.py
Function: test_getitem_with_slice
    def test_getitem_with_slice(self):
        path = Path('s.s2.s3')
        assert path[1:] == Path('s2.s3')