def test_non_recursive_locate(): fs = FileSystem() files = fs.locate(path=abspath(join(dirname(__file__), "files_to_locate")), match="*.txt", recursive=False) assert files assert isinstance(files, list) assert len(files) == 1 assert split(files[0])[-1] == "test.txt"
from copy import deepcopy from fuzzywuzzy import fuzz from itertools import chain from random import shuffle from lettuce import strings from lettuce import languages from lettuce.fs import FileSystem from lettuce.registry import STEP_REGISTRY from lettuce.registry import call_hook from lettuce.exceptions import ReasonToFail from lettuce.exceptions import NoDefinitionFound from lettuce.exceptions import LettuceSyntaxError fs = FileSystem() class REP(object): "RegEx Pattern" first_of = re.compile(ur'^first_of_') last_of = re.compile(ur'^last_of_') language = re.compile(u"language:[ ]*([^\s]+)") within_double_quotes = re.compile(r'("[^"]+")') within_single_quotes = re.compile(r"('[^']+')") only_whitespace = re.compile('^\s*$') tag_extraction_regex = re.compile(r'(?:(?:^|\s+)[@]([^@\s]+))') tag_strip_regex = re.compile(ur'(?:(?:^\s*|\s+)[@]\S+\s*)+$', re.DOTALL) comment_strip1 = re.compile(ur'(^[^\'"]*)[#]([^\'"]*)$') comment_strip2 = re.compile(ur'(^[^\'"]+)[#](.*)$')
def test_open_raw_abspath(): fs = FileSystem() assert fs.open_raw(abspath('./tests/functional/data/some.txt'), 'r').read() == 'some text here!\n'
def test_open_non_abspath(): fs = FileSystem() assert fs.open('tests/functional/data/some.txt', 'r').read() == 'some text here!\n'
def test_dirname(): fs = FileSystem() p = fs.dirname(fs.abspath(".")) p2 = dirname(abspath(".")) assert p == p2, "Expected:\n%r\nGot:\n%r" % (p2, p)
def test_join(): fs = FileSystem() p = fs.join(fs.abspath("."), "test") p2 = join(abspath("."), "test") assert p == p2, "Expected:\n%r\nGot:\n%r" % (p2, p)
def test_current_dir_without_join(): fs = FileSystem() got = fs.current_dir() expected = abspath(".") assert_equals(got, expected)
def test_current_dir_with_join(): fs = FileSystem() got = fs.current_dir("etc") expected = join(abspath("."), "etc") assert_equals(got, expected)
def test_relpath(): fs = FileSystem() p = fs.relpath(join(curdir, 'other')) p2 = join(dirname(curdir), 'other') assert_equals(p, p2)
def test_abspath(): fs = FileSystem() p = fs.abspath(".") p2 = abspath(".") assert p == p2