示例#1
0
def test_find_find_with_regexs_and_get_the_first_one_none(exists):
    ('Node#find returns the None if nothing is found')
    nd = Node('/foo/bar')
    nd.walk = Mock()
    nd.walk.return_value = [
        "/foo/wisdom/aaa.py",
        "/foo/wisdom/bbb.txt",
        "/foo/wisdom/ccc.php",
        "/foo/wisdom/ddd.py",
    ]
    ret = nd.find('^$')
    ret.should.be.none
    nd.walk.assert_called_once_with(lazy=True)
示例#2
0
def test_find_find_with_regexs_and_get_the_first_one(exists):
    ('Node#find returns the first result from find_with_regex when found')
    nd = Node('/foo/bar')
    nd.walk = Mock()
    nd.walk.return_value = [
        "/foo/wisdom/aaa.py",
        "/foo/wisdom/bbb.txt",
        "/foo/wisdom/ccc.php",
        "/foo/wisdom/ddd.py",
    ]
    ret = nd.find('[.]\w{3}$')
    ret.should.be.a(Node)
    ret.should.equal(Node("/foo/wisdom/bbb.txt"))
    nd.walk.assert_called_once_with(lazy=True)