Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,18 +2497,33 @@ def test_file_packager(self):
os.chdir('subdir')
create_file('data2.txt', 'data2')

def check(text):
self.assertGreater(len(text), 0)
empty_lines = 0
# check the generated is relatively tidy
for line in text.splitlines():
if line and line[-1].isspace():
self.fail('output contains trailing whitespace: `%s`' % line)

if line.strip():
empty_lines = 0
else:
empty_lines += 1
if empty_lines > 1:
self.fail('output contains more then one empty line in row')

# relative path to below the current dir is invalid
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--preload', '../data1.txt'])
self.assertContained('below the current directory', stderr)

# relative path that ends up under us is cool
proc = self.run_process([FILE_PACKAGER, 'test.data', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
self.assertGreater(len(proc.stdout), 0)
self.assertNotContained('below the current directory', proc.stderr)
check(proc.stdout)

# direct path leads to the same code being generated - relative path does not make us do anything different
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
self.assertGreater(len(proc2.stdout), 0)
check(proc2.stdout)
self.assertNotContained('below the current directory', proc2.stderr)

def clean(txt):
Expand Down
Loading