Skip to content
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

unittest.Test: remove('*.osc'), md5.hexdigest, osc_modif_options.source #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WK-GiHu
Copy link
Contributor

@WK-GiHu WK-GiHu commented Oct 23, 2016

Outsourced remove("tests/out/*.osc"):
Changed compare_files to use md5 hexdigest:
Adapted to new self.compare_files
Error Correction: osc_modif_options.source

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"
Copy link
Contributor Author

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'.

Copy link
Owner

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")
Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Contributor Author

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').

Copy link
Owner

@jocelynj jocelynj Oct 27, 2016

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/* ?

Copy link
Contributor Author

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)
Copy link
Contributor Author

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") )
Copy link
Contributor Author

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants