-
Notifications
You must be signed in to change notification settings - Fork 4
unittest.Test: remove('*.osc'), md5.hexdigest, osc_modif_options.source #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
unittest.Test: remove('*.osc'), md5.hexdigest, osc_modif_options.source #8
Conversation
Outsourced remove("tests/out/*.osc"): Changed compare_files to use md5 hexdigest: Adapted to new self.compare_files Error Correction: osc_modif_options.source
|
||
class osc_modif_options: | ||
source = "tests/results/001.bbox.osc" | ||
source = "tests/out/001.bbox.osc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error Correction:
The output of the previous bbox run goes to 'tests/out', therefore 'poly' run have to use the new generated file instead of a old in 'tests/results'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. This explains why the tests were working on my repository, but not on yours.
@@ -136,14 +146,14 @@ class osc_modif_options: | |||
osmbin_path = "tmp-osmbin/" | |||
osc_modif(None, osc_modif_options) | |||
|
|||
assert self.compare_files("tests/results/001.bbox.osc", "tests/out/001.bbox.osc") | |||
assert self.compare_files('03a720a5b8c79f6c1bc486be5eb1e879', "tests/out/001.bbox.osc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapted to new self.compare_files
Parameter 1: A md5 hexdigest, which you can get with command line tool md5sum
Parameter 2: File whose data md5 hexdigest to be compared with give md5 hexdigest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering: won't it be easier to keep the original file to compare, instead of putting a md5sum ? It would make it very easy to compare the two files, and check where they differ in case of failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is, because you don't answer my question regarding tests/results/*
.
For me, the Name tests/results/*
is misleading, expected unittest
would write to this directory.
How can we be sure that the data in tests/results/*
are error free?
Until now these files are only a copy from tests/out/*
. Unittest
therefore says nothing about valid datas. But regardless of this, I change compare_files(...)
to compare_files('001.bbox.osc')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry about test/results/*
. You are right that the name is misleading. This directory is intended to store the expected results of the various tests - and it is expected that files are a copy of tests/out/*
, as tests are verifying that the python code is not broken.
Maybe we could rename this directory to tests/expected/* ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about this:
DE:Referenzdaten EN: reference data FR: Données de référence
Directory Name: 'tests/ref'
Summary:
tests - Input data
tests/out - Unittest output
tests/tmp-osmbin - osmbin unittest dbase
tests/tmp-osmosis - osmosis unittest dbase, if any
tests/ref - reference data to diff tests/out if needed
Thinking about your initial question: "...check where they differ in case of failure", using a hash in unitest does not prevent to make a diff.
return filecmp.cmp(a, b) | ||
def compare_files(self, aDigest, b): | ||
from modules.helperLib import hash_file | ||
return hash_file(b).cmp(aDigest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed compare_files to use md5 hexdigest:
else: | ||
from modules.helperLib import remove | ||
# remove old <outPath>*.osc files | ||
remove( os.path.join(self.outPath, "*.osc") ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Class variable to reduce data redundancy.
Outsourced remove("tests/out/*.osc"):
Changed `self.compare_files(...)` to use Filename instead of a hash. Addapted `def compare_files(...)` to this.
Outsourced remove("tests/out/*.osc"):
Changed compare_files to use md5 hexdigest:
Adapted to new self.compare_files
Error Correction: osc_modif_options.source