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

Fix space problem in paths #78

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions needle/engines/imagemagick_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@


class Engine(EngineBase):

compare_path = "compare"
compare_command = ("{compare} -metric RMSE -subimage-search -dissimilarity-threshold 1.0 {baseline} "
"{new} {diff}")

def assertSameFiles(self, output_file, baseline_file, threshold=0):
diff_file = output_file.replace('.png', '.diff.png')

compare_cmd = self.compare_command.format(
compare=self.compare_path,
baseline=baseline_file,
new=output_file,
diff=diff_file)
process = subprocess.Popen(compare_cmd, shell=True,
compare_command = [self.compare_path,
"-metric","RMSE",
"-subimage-search",
"-dissimilarity-threshold","1.0",
baseline_file, output_file, diff_file]

process = subprocess.Popen(compare_command, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compare_stdout, compare_stderr = process.communicate()
Expand Down
30 changes: 30 additions & 0 deletions needle/engines/wand_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from wand.image import Image
import os
from needle.engines.base import EngineBase


class Engine(EngineBase):


def assertSameFiles(self, output_file, baseline_file, threshold=0):

diff_file = output_file.replace('.png', '.diff.png')

img_base = Image(filename=os.path.abspath(baseline_file))
img_out = Image(filename=os.path.abspath(output_file))

img_base.normalize()
img_out.normalize()

comparison, difference = img_base.compare(img_out, metric='root_mean_square')

if difference <= threshold:
return
else:
comparison.save(filename=diff_file)

raise AssertionError("The new screenshot '{new}' did not match "
"the baseline '{baseline}' (See {diff}):\n"
.format(new=output_file,
baseline=baseline_file,
diff=diff_file))
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def read(*parts):
'nose>=1.0.0',
'selenium>=2,<4',
'pillow',
'wand>=0.5.0'
]

if sys.version_info < (2, 7, 0):
Expand Down