From a99bb0de9bdac4bae700a1cfce3e8d4b2e755b35 Mon Sep 17 00:00:00 2001 From: Martin Olveyra Date: Fri, 8 Oct 2010 11:28:44 -0200 Subject: [PATCH] Use binary flag in read/write operations, to fix tests in windows --- scrapy/tests/test_contrib_ibl/test_htmlpage.py | 8 ++++---- scrapy/tests/test_contrib_ibl/test_pageparsing.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scrapy/tests/test_contrib_ibl/test_htmlpage.py b/scrapy/tests/test_contrib_ibl/test_htmlpage.py index a4778b9b5..cdba56853 100644 --- a/scrapy/tests/test_contrib_ibl/test_htmlpage.py +++ b/scrapy/tests/test_contrib_ibl/test_htmlpage.py @@ -43,9 +43,9 @@ def add_sample(source): while os.path.exists("%s_%d.json" % (SAMPLES_FILE_PREFIX, count)): count += 1 - open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "w").write(unicode_to_str(source)) + open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "wb").write(unicode_to_str(source)) parsed = list(parse_html(source)) - open("%s_%d.json" % (SAMPLES_FILE_PREFIX, count), "w")\ + open("%s_%d.json" % (SAMPLES_FILE_PREFIX, count), "wb")\ .write(json.dumps(parsed, default=_encode_element, indent=8)) class TestParseHtml(TestCase): @@ -96,8 +96,8 @@ class TestParseHtml(TestCase): count = 0 fname = "%s_%d.json" % (SAMPLES_FILE_PREFIX, count) while os.path.exists(fname): - source = str_to_unicode(open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "r").read()) - parsed = json.loads(str_to_unicode(open(fname, "r").read()),\ + source = str_to_unicode(open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "rb").read()) + parsed = json.loads(str_to_unicode(open(fname, "rb").read()),\ object_hook=_decode_element) self._test_sample(source, parsed, count) count += 1 diff --git a/scrapy/tests/test_contrib_ibl/test_pageparsing.py b/scrapy/tests/test_contrib_ibl/test_pageparsing.py index 1766f4aa2..ae5e1c129 100644 --- a/scrapy/tests/test_contrib_ibl/test_pageparsing.py +++ b/scrapy/tests/test_contrib_ibl/test_pageparsing.py @@ -277,8 +277,8 @@ class TestPageParsing(TestCase): count = 0 fname = "%s_%d.json" % (SAMPLES_FILE_PREFIX, count) while os.path.exists(fname): - source = str_to_unicode(open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "r").read()) - annotations = json.loads(str_to_unicode(open(fname, "r").read())) + source = str_to_unicode(open("%s_%d.html" % (SAMPLES_FILE_PREFIX, count), "rb").read()) + annotations = json.loads(str_to_unicode(open(fname, "rb").read())) template = HtmlPage(body=source) parser = TemplatePageParser(TokenDict()) parser.feed(template)