File 0001-Open-XML-files-in-binary-mode.patch of Package python3-musicbrainzngs
From 3ff4ace30954b6254ada397089bf594229bcb336 Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefano@rivera.za.net>
Date: Sat, 20 Aug 2016 19:48:51 -0700
Subject: [PATCH] Open XML files in binary mode, as they contain non-ASCII
Signed-off-by: Stefano Rivera <stefano@rivera.za.net>
---
test/_common.py | 2 +-
test/test_mbxml_search.py | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/test/_common.py b/test/_common.py
index e8b7713..8b51707 100644
--- a/test/_common.py
+++ b/test/_common.py
@@ -70,6 +70,6 @@ def open_and_parse_test_data(datadir, filename):
:returns: The parsed representation of the XML files content
"""
- with open(join(datadir, filename)) as msg:
+ with open(join(datadir, filename), 'rb') as msg:
res = musicbrainzngs.mbxml.parse_message(msg)
return res
diff --git a/test/test_mbxml_search.py b/test/test_mbxml_search.py
index c941626..fd13777 100644
--- a/test/test_mbxml_search.py
+++ b/test/test_mbxml_search.py
@@ -57,7 +57,7 @@ def testSearchWork(self):
class SearchArtistTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-artist.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(25, len(res["artist-list"]))
self.assertEqual(349, res["artist-count"])
@@ -70,7 +70,7 @@ def testFields(self):
class SearchReleaseTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-release.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(25, len(res["release-list"]))
self.assertEqual(16739, res["release-count"])
@@ -85,7 +85,7 @@ def testFields(self):
class SearchReleaseGroupTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-release-group.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(25, len(res["release-group-list"]))
self.assertEqual(14641, res["release-group-count"])
@@ -95,7 +95,7 @@ def testFields(self):
class SearchWorkTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-work.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(25, len(res["work-list"]))
self.assertEqual(174, res["work-count"])
@@ -105,7 +105,7 @@ def testFields(self):
class SearchLabelTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-label.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(1, len(res["label-list"]))
self.assertEqual(1, res["label-count"])
@@ -115,7 +115,7 @@ def testFields(self):
class SearchRecordingTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-recording.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(25, len(res["recording-list"]))
self.assertEqual(1258, res["recording-count"])
@@ -125,7 +125,7 @@ def testFields(self):
class SearchInstrumentTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-instrument.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(23, len(res["instrument-list"]))
self.assertEqual(23, res["instrument-count"])
@@ -137,7 +137,7 @@ def testFields(self):
class SearchPlaceTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-place.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(14, res["place-count"])
self.assertEqual(14, len(res["place-list"]))
@@ -150,7 +150,7 @@ def testFields(self):
class SearchEventTest(unittest.TestCase):
def testFields(self):
fn = os.path.join(DATA_DIR, "search-event.xml")
- with open(fn) as msg:
+ with open(fn, 'rb') as msg:
res = mbxml.parse_message(msg)
self.assertEqual(3, res["event-count"])
self.assertEqual(3, len(res["event-list"]))