From 124c16d401d3a8e473886dcb0b02c026ddcfd97d Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Wed, 24 Nov 2010 22:09:28 +0000 Subject: implement a new numdb module to hold information on hierarchically organised numbers and switch the isbn module to use this format instead git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@42 9dea7c4f-944c-4273-ac1a-574ede026edc --- tests/test_isbn.doctest | 79 ------------------------------------------------- 1 file changed, 79 deletions(-) (limited to 'tests/test_isbn.doctest') diff --git a/tests/test_isbn.doctest b/tests/test_isbn.doctest index fc6a7b9..8073645 100644 --- a/tests/test_isbn.doctest +++ b/tests/test_isbn.doctest @@ -77,82 +77,3 @@ Regrouping tests. ('', '99996', '', '7827', '0') >>> isbn.split('979-20-1234567-8') ('979', '', '', '201234567', '8') - - -Some tests for the ranges module. This is more an internal module so -tests here are not very critical. - ->>> from stdnum.isbn import ranges ->>> list(ranges._wrap(2 * 'abc def ghijklmn opqr stuvwx yz', 40))[0] -'abc def ghijklmn opqr stuvwx yzabc def' - - -Test output function. Bit of a limited test but we see if the serialised -form of the prefix/ranges list contains at least the same prefixes as the -current _prefixes list. - ->>> import StringIO ->>> output = StringIO.StringIO() ->>> ranges.output(output) ->>> k = set( x.split(' ')[0] for x in StringIO.StringIO(output.getvalue()).readlines() ) ->>> k == set(ranges._prefixes.keys()) -True - - -Make an XML file with somre prefix definitions and load that into the -ranges module. - -First save the current ranges so we can restore later. - ->>> save_prefixes = ranges._prefixes - -Write the XML to a file. - ->>> import tempfile ->>> xmlfile = tempfile.NamedTemporaryFile(delete=False) ->>> xmlfile.write(""" -... -... 0aad2b046ddd9b30e080cb2b24afc868 -... Thu, 20 May 2010 18:36:55 GMT -... -... 978 -... -... 0000000-59999991 -... 6000000-64999993 -... 6500000-69999990 -... -... -... -... -... 978-0 -... -... 0000000-19999992 -... 2000000-69999993 -... -... -... -... -... """) ->>> xmlfile.close() - -Load the XML file by URL and output it to another string. Check if the -content of the XML has been - ->>> import urllib ->>> ranges.download('file://' + urllib.pathname2url(xmlfile.name)) ->>> import sys ->>> ranges.output() -# generated from RangeMessage.xml, downloaded from -# http://www.isbn-international.org/agency?rmxml=1 -# serial 0aad2b046ddd9b30e080cb2b24afc868 -# date Thu, 20 May 2010 18:36:55 GMT -_prefixes = """ -978 0-5 600-649 -978-0 00-19 200-699 -""" - -Restore the original ranges and clean up. - ->>> ranges._prefixes = save_prefixes ->>> import os ->>> os.unlink(xmlfile.name) -- cgit v1.2.3