14
0

- Update to version 2.3.0+git.1546912853.bf348d6:

* Update CHANGES to include note on fixing issue #65; generalized the note about the decaf language example; added sample code from the statemachine examples.
  * Unit test to test fix for issue #65
  * Fix inconsistency between Keyword(caseless=True) and CaselessKeyword (issue #65)
  * Fix typo: 'chemcialFormulas.py' -> 'chemicalFormulas.py'
  * Convert exception logging to use ParseException.explain()
  * Add experimental ParseException.explain() method, to return a multiline string showing the parse expressions leading to a parsing failure
  * Clean up CHANGES notes for new examples
  * Add document signoff and library book state examples;
  * Update statemachine demo code to Py3
  * Update Lucene grammar example, but remove from Travis-CI acceptance scripts

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pyparsing?expand=0&rev=57
This commit is contained in:
2019-01-08 20:06:45 +00:00
committed by Git OBS Bridge
parent f75677a570
commit a099b5dda4
9 changed files with 57 additions and 4316 deletions

View File

@@ -1,18 +1,16 @@
--- a/examples/test_bibparse.py
+++ b/examples/test_bibparse.py
@@ -1,193 +1,193 @@
@@ -1,191 +1,192 @@
""" Test for bibparse grammar """
+import unittest
from os.path import join as pjoin, dirname
from pyparsing import ParseException
from .btpyparse import Macro
from . import btpyparse as bp
-from nose.tools import assert_true, assert_false, assert_equal, assert_raises
-from nose.tools import assert_equal, assert_raises
-
-def test_names():
- # check various types of names
- # All names can contains alphas, but not some special chars
@@ -26,8 +24,8 @@
- else:
- assert_raises(ParseException, name_type.parseString, '2t')
- # All of the names cannot contain some characters
+class TestBibparse(unittest.TestCase):
+ def test_names():
+class TestBibParse(unittest.TestCase):
+ def test_names(self):
+ # check various types of names
+ # All names can contains alphas, but not some special chars
+ bad_chars = '"#%\'(),={}'
@@ -218,7 +216,7 @@
+ self.assertEqual(mr.parseString('simple_test')[0].name, 'simple_test')
+
+
+ def test_numbers():
+ def test_numbers(self):
+ self.assertEqual(bp.number.parseString('1066')[0], '1066')
+ self.assertEqual(bp.number.parseString('0')[0], '0')
+ self.assertRaises(ParseException, bp.number.parseString, '-4')
@@ -228,7 +226,7 @@
+ self.assertEqual(bp.number.parseString('0.4')[0], '0')
+
+
+ def test_parse_string():
+ def test_parse_string(self):
+ # test string building blocks
+ self.assertEqual(bp.chars_no_quotecurly.parseString('x')[0], 'x')
+ self.assertEqual(bp.chars_no_quotecurly.parseString("a string")[0], 'a string')
@@ -259,7 +257,7 @@
+ self.assertEqual(bp.string.parseString('1994')[0], '1994')
+
+
+ def test_parse_field():
+ def test_parse_field(self):
+ # test field value - hashes included
+ fv = bp.field_value
+ # Macro
@@ -279,7 +277,7 @@
+ ['a string', '1994', Macro('a_macro')])
+
+
+ def test_comments():
+ def test_comments(self):
+ res = bp.comment.parseString('@Comment{about something}')
+ self.assertEqual(res.asList(), ['comment', '{about something}'])
+ self.assertEqual(
@@ -299,7 +297,7 @@
+ '@comment"about something')
+
+
+ def test_preamble():
+ def test_preamble(self):
+ res = bp.preamble.parseString('@preamble{"about something"}')
+ self.assertEqual(res.asList(), ['preamble', 'about something'])
+ self.assertEqual(bp.preamble.parseString(
@@ -311,7 +309,7 @@
+ ['preamble', 'about something'])
+
+
+ def test_macro():
+ def test_macro(self):
+ res = bp.macro.parseString('@string{ANAME = "about something"}')
+ self.assertEqual(res.asList(), ['string', 'aname', 'about something'])
+ self.assertEqual(
@@ -319,7 +317,7 @@
+ ['string', 'aname', 'about something'])
+
+
+ def test_entry():
+ def test_entry(self):
+ txt = """@some_entry{akey, aname = "about something",
+ another={something else}}"""
+ res = bp.entry.parseString(txt)
@@ -335,7 +333,7 @@
+ ['aname', 'about something'], ['another', 'something else']])
+
+
+ def test_bibfile():
+ def test_bibfile(self):
+ txt = """@some_entry{akey, aname = "about something",
+ another={something else}}"""
+ res = bp.bibfile.parseString(txt)
@@ -345,7 +343,7 @@
+ ['another', 'something else']]])
+
+
+ def test_bib1():
+ def test_bib1(self):
+ # First pass whole bib-like tests
+ txt = """
+ Some introductory text