Esempio n. 1
0
def test_sd_false_via_constructor():
    try:
        fs = FilesystemTree(should_dedent=False)
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == '    Greetings, program!'
    finally:
        fs.remove()
Esempio n. 2
0
def test_encoding_cp1140_via_constructor():
    try:
        fs = FilesystemTree(encoding='cp1140')
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_CP1140
    finally:
        fs.remove()
Esempio n. 3
0
def test_encoding_cp1140_via_constructor():
    try:
        fs = FilesystemTree(encoding='cp1140')
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_CP1140
    finally:
        fs.remove()
Esempio n. 4
0
def test_sd_false_via_constructor():
    try:
        fs = FilesystemTree(should_dedent=False)
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == '    Greetings, program!'
    finally:
        fs.remove()
Esempio n. 5
0
def test_encoding_utf8_via_instance_attribute():
    try:
        fs = FilesystemTree(encoding='cp1140')
        fs.encoding = 'utf8'
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_UTF8
    finally:
        fs.remove()
Esempio n. 6
0
def test_sd_true_via_instance_attribute():
    try:
        fs = FilesystemTree(should_dedent=False)
        fs.should_dedent = True
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == 'Greetings, program!'
    finally:
        fs.remove()
Esempio n. 7
0
def test_encoding_utf8_via_instance_attribute():
    try:
        fs = FilesystemTree(encoding='cp1140')
        fs.encoding = 'utf8'
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_UTF8
    finally:
        fs.remove()
Esempio n. 8
0
def test_sd_true_via_instance_attribute():
    try:
        fs = FilesystemTree(should_dedent=False)
        fs.should_dedent = True
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == 'Greetings, program!'
    finally:
        fs.remove()
Esempio n. 9
0
def test_encoding_cp1140_via_class_attribute():
    _reset = FilesystemTree.encoding
    try:
        FilesystemTree.encoding = 'cp1140'
        fs = FilesystemTree()
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_CP1140
    finally:
        FilesystemTree.encoding = _reset
        fs.remove()
Esempio n. 10
0
def test_encoding_utf8_via_constructor():
    _reset = FilesystemTree.encoding
    try:
        FilesystemTree.encoding = 'cp1140'
        fs = FilesystemTree(encoding='utf8')
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_UTF8
    finally:
        FilesystemTree.encoding = _reset
        fs.remove()
Esempio n. 11
0
def test_sd_false_via_class_attribute():
    _reset = FilesystemTree.should_dedent
    try:
        FilesystemTree.should_dedent = False
        fs = FilesystemTree()
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == '    Greetings, program!'
    finally:
        FilesystemTree.should_dedent = _reset
        fs.remove()
Esempio n. 12
0
def test_encoding_cp1140_via_class_attribute():
    _reset = FilesystemTree.encoding
    try:
        FilesystemTree.encoding = 'cp1140'
        fs = FilesystemTree()
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_CP1140
    finally:
        FilesystemTree.encoding = _reset
        fs.remove()
Esempio n. 13
0
def test_encoding_utf8_via_constructor():
    _reset = FilesystemTree.encoding
    try:
        FilesystemTree.encoding = 'cp1140'
        fs = FilesystemTree(encoding='utf8')
        fs.mk(('file.txt', A_UNICODE))
        contents = open(fs.resolve('file.txt'), 'rb').read()
        assert contents == AS_UTF8
    finally:
        FilesystemTree.encoding = _reset
        fs.remove()
Esempio n. 14
0
def test_sd_false_via_class_attribute():
    _reset = FilesystemTree.should_dedent
    try:
        FilesystemTree.should_dedent = False
        fs = FilesystemTree()
        fs.mk(('some/dir/file.txt', '    Greetings, program!'))
        contents = open(fs.resolve('some/dir/file.txt')).read()
        assert contents == '    Greetings, program!'
    finally:
        FilesystemTree.should_dedent = _reset
        fs.remove()
Esempio n. 15
0
class RunDeployHooks(DeployHooksHarness):
    def setUp(self):
        self.ft = FilesystemTree()
        self.db.run('DROP TABLE IF EXISTS foo;')

    def tearDown(self):
        self.ft.remove()
        self.db.run('DROP TABLE IF EXISTS foo;')

    def test_runs_deploy_hooks(self):
        self.ft.mk(('before.sql', 'CREATE TABLE foo (bar int);'),
                   ('after.py', AFTER_PY),
                   ('after.sql', 'ALTER TABLE foo RENAME COLUMN bar TO baz;'))

        raises(ProgrammingError, self.db.all, 'SELECT name FROM foo')
        self.run_deploy_hooks(_deploy_dir=self.ft.root)
        assert self.db.all('SELECT baz FROM foo ORDER BY baz') == [42, 537]
Esempio n. 16
0
def fs():
    fs = FilesystemTree()
    yield fs
    fs.remove()