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
3
Example 1
@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
3
Example 2
@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
3
Example 3
@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
0
Example 4
def test_init(self, SubSection):
path = AttrPath(SubSection, 'section.docuement')
assert path.class_ == SubSection
assert path.path == Path('section.docuement')
0
Example 5
def test_init(self):
path = Path('attr.attr2')
assert path.path == 'attr.attr2'
0
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'
0
Example 7
def test_iter(self):
path = Path('s.s2.s3')
assert list(path) == ['s', 's2', 's3']
0
Example 8
def test_reversed(self):
path = Path('s.s2.s3')
assert list(reversed(path)) == ['s3', 's2', 's']
0
Example 9
def test_repr(self):
path = Path('s.s2')
assert repr(path) == "Path('s.s2')"
0
Example 10
def test_getitem(self):
path = Path('s.s2')
assert path[0] == 's'
assert path[1] == 's2'
0
Example 11
def test_str(self):
assert str(Path('s.s2')) == 's.s2'
0
Example 12
def test_index(self):
assert Path('s.s2.s3').index('s2') == 1
0
Example 13
def test_unicode(self):
assert six.text_type(Path('s.s2')) == u's.s2'
0
Example 14
def test_getitem_with_slice(self):
path = Path('s.s2.s3')
assert path[1:] == Path('s2.s3')