Commit
318d3b716a148f3f0624d8aefcf6a98daa6e1536
unittest: move test data reader to util dir
With this change we replace the relative import.
Also use with-statement to open test file, so file is always closed after
reading (python3 unittest issued a warning).
|
1
| import unittest, sys, os |
1
| import unittest, sys, os |
|
2
| |
2
| |
|
3
| -from .. import testdata_reader |
3
| +from tests.test_utils import testdata_reader |
|
4
| from oletools import rtfobj |
4
| from oletools import rtfobj |
|
5
| |
5
| |
|
6
| class TestRtfObjIssue185(unittest.TestCase): |
6
| class TestRtfObjIssue185(unittest.TestCase): |
|
| |
1
| +import os |
|
| |
2
| +from os.path import dirname, abspath, normpath, join |
|
| |
3
| +from . import DATA_BASE_DIR |
|
| |
4
| + |
|
| |
5
| + |
|
| |
6
| +def read(relative_path): |
|
| |
7
| + with open(join(DATA_BASE_DIR, relative_path), 'rb') as file_handle: |
|
| |
8
| + return file_handle.read() |
|
1
| -import os |
| |
|
2
| - |
| |
|
3
| -def read(relative_path): |
| |
|
4
| - test_data = os.path.dirname(os.path.abspath(__file__)) + '/test-data/' |
| |
|
5
| - return open(test_data + relative_path, 'rb').read() |
| |
|
6
| - |
| |