Skip to content

Commit fd226e0

Browse files
Gergrobdimsdale
authored andcommitted
Update file counting test
- It is annoying to only assert on integer equality for count of files in a directory (what files?). Add assertions for the desired files. - Reduce the aforementioned integer. This is because python2 would put compiled .pyc files in the same directory as the source .py files. In python3, the .pyc files go in a __pycache__ directory. - Print slightly more helpful failure message if the integers don't match
1 parent 8b6282b commit fd226e0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tests/common/components.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ def assert_scripts_are_installed(self, build_dir):
3838
(fah.expect()
3939
.path(build_dir, '.bp', 'bin', 'rewrite')
4040
.root(build_dir, '.bp', 'lib', 'build_pack_utils')
41-
.directory_count_equals(20) # noqa
42-
.path('utils.py')
41+
.directory_count_equals(11) # noqa
42+
.path('__init__.py')
43+
.path('__pycache__')
44+
.path('builder.py')
45+
.path('cloudfoundry.py')
46+
.path('compile_extensions.py')
47+
.path('detecter.py') # [sic]
48+
.path('downloads.py')
4349
.path('process.py')
50+
.path('runner.py')
51+
.path('utils.py')
52+
.path('zips.py')
4453
.exists())
4554

4655
def assert_config_options(self, build_dir):

tests/common/integration.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ def does_not_exist(self):
128128

129129
def directory_count_equals(self, cnt):
130130
root = os.path.join(*self._root)
131+
actual = len(os.listdir(root))
131132
assert \
132-
len(os.listdir(root)) == cnt, \
133-
"Directory [%s] does not contain [%d] files" % (root, cnt)
133+
actual == cnt, \
134+
"Directory [%s] contains [%d] files, expected [%d] files" % (root, actual, cnt)
134135
return self
135136

136137

0 commit comments

Comments
 (0)