diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 7148dfc..8454b98 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -14,12 +14,12 @@ jobs:
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up Python
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v5
with:
- python-version: 3.8
+ python-version: 3.10
- name: Build distribution
run: python -m pip install build && python -m build
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d6d790c..7d62070 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -8,17 +8,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.7, 3.8, 3.9]
+ python-version: ["3.9", "3.10", "3.11"]
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
+
- name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -e '.[test]'
- - name: Test with nosetests
- run: nosetests
+ run: pip install -e '.[test]'
+
+ - name: Run tests
+ run: python -m unittest
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d104d96..cc96371 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 9.0.0
+
+- Dropped support for Python < 3.10 (no other changes)
+
## 8.0.0
- Parser now accepts both strings and bytes, and will encode strings to bytes using UTF-8
diff --git a/README.md b/README.md
index 163baeb..83f1132 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ Use it like this:
## Releasing a new version
-1. Run the tests with `nosetests`
+1. Run the tests with `python -m unittest`
2. Update the version by changing the `__version__` variable in [`cobalt/__init__.py`](cobalt/__init__.py)
3. Commit your changes and push to the master branch on GitHub
4. Create a release in GitHub and it will automatically be pushed to PyPi
diff --git a/cobalt/__init__.py b/cobalt/__init__.py
index 738b0c7..caeba1c 100644
--- a/cobalt/__init__.py
+++ b/cobalt/__init__.py
@@ -8,7 +8,7 @@
from .portion import PortionStructure, Portion
from .uri import FrbrUri
-__version__ = '8.0.1'
+__version__ = '9.0.0'
__all__ = [
'Act', 'AkomaNtosoDocument', 'Amendment', 'AmendmentEvent', 'AmendmentList', 'AmendmentStructure',
diff --git a/pyproject.toml b/pyproject.toml
index 1c3edb0..9d1848b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ authors = [
]
license = {text = "LGPLv3+"}
readme = "README.md"
-requires-python = ">=3.7"
+requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
@@ -32,7 +32,7 @@ dynamic = ["version"]
"Bug Tracker" = "https://github.com/laws-africa/cobalt/issues"
[project.optional-dependencies]
-test = ["nose", "flake8"]
+test = ["flake8"]
[tool.setuptools.packages.find]
include = ["cobalt"] # package names should match these glob patterns (["*"] by default)
diff --git a/tests/test_act.py b/tests/test_act.py
index 4f32e5c..b910cf2 100644
--- a/tests/test_act.py
+++ b/tests/test_act.py
@@ -1,5 +1,4 @@
from unittest import TestCase
-from nose.tools import * # noqa
from datetime import date
from lxml.etree import LxmlSyntaxError
@@ -13,45 +12,45 @@ class ActTestCase(TestCase):
def test_empty_act(self):
a = Act()
- assert_equal(a.title, "Untitled")
- assert_is_not_none(a.meta)
- assert_is_not_none(a.body)
+ self.assertEqual(a.title, "Untitled")
+ self.assertIsNotNone(a.meta)
+ self.assertIsNotNone(a.body)
assert_validates(a)
def test_empty_body(self):
a = Act()
- assert_not_equal(a.body.text, '')
+ self.assertNotEqual(a.body.text, '')
assert_validates(a)
def test_publication_date(self):
a = Act()
- assert_is_none(a.publication_date)
+ self.assertIsNone(a.publication_date)
assert_validates(a)
a.publication_date = '2012-01-02'
- assert_equal(datestring(a.publication_date), '2012-01-02')
- assert_is_instance(a.publication_date, date)
+ self.assertEqual(datestring(a.publication_date), '2012-01-02')
+ self.assertIsInstance(a.publication_date, date)
assert_validates(a)
a.publication_date = None
- assert_is_none(a.publication_date)
+ self.assertIsNone(a.publication_date)
assert_validates(a)
def test_publication_number(self):
a = Act()
- assert_is_none(a.publication_number)
+ self.assertIsNone(a.publication_number)
a.publication_number = '1234'
- assert_equal(a.publication_number, '1234')
+ self.assertEqual(a.publication_number, '1234')
assert_validates(a)
def test_publication_name(self):
a = Act()
- assert_is_none(a.publication_name)
+ self.assertIsNone(a.publication_name)
a.publication_name = 'Publication'
- assert_equal(a.publication_name, 'Publication')
+ self.assertEqual(a.publication_name, 'Publication')
assert_validates(a)
def test_set_amendments(self):
@@ -169,14 +168,14 @@ def test_set_amendments(self):
""", xml)
amendment = a.amendments[0]
- assert_equal(datestring(amendment.date), '2012-02-01')
- assert_equal(amendment.amending_uri, '/za/act/1980/22')
- assert_equal(amendment.amending_title, 'Corrected')
+ self.assertEqual(datestring(amendment.date), '2012-02-01')
+ self.assertEqual(amendment.amending_uri, '/za/act/1980/22')
+ self.assertEqual(amendment.amending_title, 'Corrected')
amendment = a.amendments[1]
- assert_equal(datestring(amendment.date), '2013-03-03')
- assert_equal(amendment.amending_uri, '/za/act/1990/5')
- assert_equal(amendment.amending_title, 'Bar')
+ self.assertEqual(datestring(amendment.date), '2013-03-03')
+ self.assertEqual(amendment.amending_uri, '/za/act/1990/5')
+ self.assertEqual(amendment.amending_title, 'Bar')
assert_validates(a)
@@ -283,15 +282,15 @@ def test_set_repeal(self):
""", xml)
- assert_equal(a.repeal.repealing_uri, '/za/act/1980/10')
- assert_equal(a.repeal.repealing_title, 'Foo')
- assert_equal(datestring(a.repeal.date), '2012-02-01')
+ self.assertEqual(a.repeal.repealing_uri, '/za/act/1980/10')
+ self.assertEqual(a.repeal.repealing_title, 'Foo')
+ self.assertEqual(datestring(a.repeal.date), '2012-02-01')
assert_validates(a)
# check that clearing it works
a.repeal = None
- assert_is_none(a.repeal)
+ self.assertIsNone(a.repeal)
assert_validates(a)
diff --git a/tests/test_attachments.py b/tests/test_attachments.py
index a445bfd..ab198e1 100644
--- a/tests/test_attachments.py
+++ b/tests/test_attachments.py
@@ -1,11 +1,11 @@
from unittest import TestCase
-from nose.tools import * # noqa
from lxml import etree
from cobalt import Act
from cobalt.schemas import assert_validates
+
class AttachmentsTestCase(TestCase):
maxDiff = None
diff --git a/tests/test_debate.py b/tests/test_debate.py
new file mode 100644
index 0000000..343cee5
--- /dev/null
+++ b/tests/test_debate.py
@@ -0,0 +1,21 @@
+from unittest import TestCase
+
+from cobalt import Debate
+
+
+class DebateTestCase(TestCase):
+ maxDiff = None
+
+ def test_empty_debate(self):
+ d = Debate()
+ self.assertEqual(d.title, "Untitled")
+ self.assertIsNotNone(d.meta)
+ self.assertIsNotNone(d.debateBody)
+
+ def test_empty_body(self):
+ d = Debate()
+ self.assertNotEqual(d.debateBody.text, '')
+
+ def test_main(self):
+ d = Debate()
+ self.assertEqual(d.main, d.debate)
diff --git a/tests/test_judgment.py b/tests/test_judgment.py
index c135833..60598bd 100644
--- a/tests/test_judgment.py
+++ b/tests/test_judgment.py
@@ -1,5 +1,4 @@
from unittest import TestCase
-from nose.tools import * # noqa
from cobalt import Judgment
@@ -9,13 +8,13 @@ class JudgmentTestCase(TestCase):
def test_empty_judgment(self):
j = Judgment()
- assert_equal(j.title, "Untitled")
- assert_is_not_none(j.meta)
- assert_is_not_none(j.judgmentBody)
+ self.assertEqual(j.title, "Untitled")
+ self.assertIsNotNone(j.meta)
+ self.assertIsNotNone(j.judgmentBody)
def test_empty_body(self):
j = Judgment()
- assert_not_equal(j.judgmentBody.text, '')
+ self.assertNotEqual(j.judgmentBody.text, '')
def test_main(self):
j = Judgment()
diff --git a/tests/test_structured_document.py b/tests/test_structured_document.py
index 3717cff..5e3db7f 100644
--- a/tests/test_structured_document.py
+++ b/tests/test_structured_document.py
@@ -1,5 +1,4 @@
from unittest import TestCase
-from nose.tools import * # noqa
from datetime import date
from cobalt import Act, datestring
@@ -17,22 +16,22 @@ def test_frbr_uri(self):
a.frbr_uri = '/zm/act/2007/01'
today = datestring(date.today())
- assert_equal(a.frbr_uri.work_uri(), '/zm/act/2007/01')
+ self.assertEqual(a.frbr_uri.work_uri(), '/zm/act/2007/01')
- assert_equal(a.meta.identification.FRBRWork.FRBRthis.get('value'), '/zm/act/2007/01/!main')
- assert_equal(a.meta.identification.FRBRWork.FRBRuri.get('value'), '/zm/act/2007/01')
- assert_equal(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm')
- assert_equal(a.meta.identification.FRBRWork.FRBRnumber.get('value'), '01')
- assert_equal(a.meta.identification.FRBRWork.FRBRdate.get('date'), '2007')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRthis.get('value'), '/zm/act/2007/01/!main')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRuri.get('value'), '/zm/act/2007/01')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRnumber.get('value'), '01')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRdate.get('date'), '2007')
- assert_equal(a.meta.identification.FRBRExpression.FRBRthis.get('value'), '/zm/act/2007/01/eng@2012-01-01/!main')
- assert_equal(a.meta.identification.FRBRExpression.FRBRuri.get('value'), '/zm/act/2007/01/eng@2012-01-01')
- assert_equal(a.meta.identification.FRBRExpression.FRBRdate.get('date'), '2012-01-01')
+ self.assertEqual(a.meta.identification.FRBRExpression.FRBRthis.get('value'), '/zm/act/2007/01/eng@2012-01-01/!main')
+ self.assertEqual(a.meta.identification.FRBRExpression.FRBRuri.get('value'), '/zm/act/2007/01/eng@2012-01-01')
+ self.assertEqual(a.meta.identification.FRBRExpression.FRBRdate.get('date'), '2012-01-01')
- assert_equal(a.meta.identification.FRBRManifestation.FRBRthis.get('value'),
+ self.assertEqual(a.meta.identification.FRBRManifestation.FRBRthis.get('value'),
'/zm/act/2007/01/eng@2012-01-01/!main')
- assert_equal(a.meta.identification.FRBRManifestation.FRBRuri.get('value'), '/zm/act/2007/01/eng@2012-01-01')
- assert_equal(a.meta.identification.FRBRManifestation.FRBRdate.get('date'), today)
+ self.assertEqual(a.meta.identification.FRBRManifestation.FRBRuri.get('value'), '/zm/act/2007/01/eng@2012-01-01')
+ self.assertEqual(a.meta.identification.FRBRManifestation.FRBRdate.get('date'), today)
assert_validates(a)
@@ -41,10 +40,10 @@ def test_frbr_country(self):
a.expression_date = '2012-01-01'
a.frbr_uri = '/zm/act/2007/01'
- assert_equal(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm')
a.frbr_uri = '/zm-abc123/act/2007/01'
- assert_equal(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm-abc123')
+ self.assertEqual(a.meta.identification.FRBRWork.FRBRcountry.get('value'), 'zm-abc123')
def test_title(self):
a = Act()
@@ -69,34 +68,34 @@ def test_work_date(self):
"""
a = Act()
a.frbr_uri = '/akn/za/act/2012-01-02/5'
- assert_equal(datestring(a.work_date), '2012-01-02')
- assert_is_instance(a.work_date, date)
+ self.assertEqual(datestring(a.work_date), '2012-01-02')
+ self.assertIsInstance(a.work_date, date)
a.frbr_uri = '/akn/za/act/2009/5'
- assert_equal(datestring(a.work_date), '2009-01-01')
- assert_is_instance(a.work_date, date)
+ self.assertEqual(datestring(a.work_date), '2009-01-01')
+ self.assertIsInstance(a.work_date, date)
def test_expression_date(self):
a = Act()
a.expression_date = '2012-01-02'
- assert_equal(datestring(a.expression_date), '2012-01-02')
- assert_is_instance(a.expression_date, date)
+ self.assertEqual(datestring(a.expression_date), '2012-01-02')
+ self.assertIsInstance(a.expression_date, date)
def test_manifestation_date(self):
a = Act()
a.manifestation_date = '2012-01-02'
- assert_equal(datestring(a.manifestation_date), '2012-01-02')
- assert_is_instance(a.manifestation_date, date)
+ self.assertEqual(datestring(a.manifestation_date), '2012-01-02')
+ self.assertIsInstance(a.manifestation_date, date)
def test_language(self):
a = Act()
a.language = 'fre'
- assert_equal(a.language, 'fre')
+ self.assertEqual(a.language, 'fre')
def test_namespaces(self):
# default is now AKN3
a = Act()
- assert_equal(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
+ self.assertEqual(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
# prefer AKN3 when both 2 and 3 are listed as namespaces
a = Act(xml="""
@@ -110,7 +109,7 @@ def test_namespaces(self):
""")
- assert_equal(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
+ self.assertEqual(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
# prefer AKN2 when 2 and something else are listed as namespaces
a = Act(xml="""
@@ -120,10 +119,10 @@ def test_namespaces(self):
""")
- assert_equal(a.namespace, 'http://www.akomantoso.org/2.0')
+ self.assertEqual(a.namespace, 'http://www.akomantoso.org/2.0')
# throw error if neither of AKN2 and AKN3 are listed as namespaces
- with assert_raises(ValueError) as raised:
+ with self.assertRaises(ValueError) as raised:
Act(xml="""
@@ -131,7 +130,7 @@ def test_namespaces(self):
""")
- assert_in(
+ self.assertIn(
"Expected to find one of the following Akoma Ntoso XML namespaces: http://docs.oasis-open.org/legaldocml/ns/akn/3.0, http://www.akomantoso.org/2.0. Only these namespaces were found: http://www.w3.org/2001/XMLSchema-instance, http://www.akomantoso.org/4.0, http://docs.oasis-open.org/legaldocml/ns/akn/5.0",
raised.exception.args)
@@ -151,7 +150,7 @@ def test_namespaces(self):
""")
- assert_equal(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
+ self.assertEqual(a.namespace, 'http://docs.oasis-open.org/legaldocml/ns/akn/3.0')
self.assertEqual("This content should NOT be ignored as it's using the AKN3 namespace.", a.body.section.content.p)
self.assertNotIn("This content SHOULD be ignored as it's not using the AKN3 namespace.", a.body.section.content.p)
self.assertNotIn("This content should ALSO be ignored as it's using the AKN2 namespace.", a.body.section.content.p)
@@ -162,28 +161,28 @@ def test_parser(self):
a.parse(a.to_xml(), a.document_type)
# error if root isn't `akomaNtoso`
- with assert_raises(ValueError) as raised:
+ with self.assertRaises(ValueError) as raised:
a.parse("""
Whaddup, fam!
""", a.document_type)
- assert_in("XML root element must be akomaNtoso, but got myBlog instead", raised.exception.args)
+ self.assertIn("XML root element must be akomaNtoso, but got myBlog instead", raised.exception.args)
# error if root as no children
- with assert_raises(ValueError) as raised:
+ with self.assertRaises(ValueError) as raised:
a.parse("""
""", a.document_type)
- assert_in("Expected act as a child of root element", raised.exception.args)
+ self.assertIn("Expected act as a child of root element", raised.exception.args)
# error if `act` isn't first child
- with assert_raises(ValueError) as raised:
+ with self.assertRaises(ValueError) as raised:
a.parse("""
""", a.document_type)
- assert_in("Expected act as a child of root element", raised.exception.args)
+ self.assertIn("Expected act as a child of root element", raised.exception.args)
# allow comments at the top level
a.parse("""
diff --git a/tests/test_uri.py b/tests/test_uri.py
index b89a4bb..63120a9 100644
--- a/tests/test_uri.py
+++ b/tests/test_uri.py
@@ -1,199 +1,198 @@
from unittest import TestCase
-from nose.tools import *
from cobalt.uri import FrbrUri
class FrbrUriTestCase(TestCase):
def test_bad_value(self):
- assert_raises(ValueError, FrbrUri.parse, "/badness")
- assert_raises(ValueError, FrbrUri.parse, "/ukpga/2015/1")
+ self.assertRaises(ValueError, FrbrUri.parse, "/badness")
+ self.assertRaises(ValueError, FrbrUri.parse, "/ukpga/2015/1")
def test_simple(self):
uri = FrbrUri.parse("/akn/za/act/1980/01")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, None)
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
- assert_equal(uri.prefix, "akn")
-
- assert_equal("/akn/za/act/1980/01", uri.work_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, None)
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+ self.assertEqual(uri.prefix, "akn")
+
+ self.assertEqual("/akn/za/act/1980/01", uri.work_uri())
def test_with_subtype(self):
uri = FrbrUri.parse("/akn/za/act/by-law/1980/01")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, None)
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, "by-law")
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za/act/by-law/1980/01", uri.work_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, None)
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, "by-law")
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za/act/by-law/1980/01", uri.work_uri())
def test_with_locality(self):
uri = FrbrUri.parse("/akn/za-cpt/act/by-law/1980/01")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, "cpt")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, "by-law")
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za-cpt/act/by-law/1980/01", uri.work_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, "cpt")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, "by-law")
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za-cpt/act/by-law/1980/01", uri.work_uri())
def test_with_subtype_and_actor(self):
uri = FrbrUri.parse("/akn/za/act/by-law/actor/1980/01")
- assert_equal(uri.country, "za")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, "by-law")
- assert_equal(uri.actor, "actor")
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, "by-law")
+ self.assertEqual(uri.actor, "actor")
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
- assert_equal("/akn/za/act/by-law/actor/1980/01", uri.work_uri())
+ self.assertEqual("/akn/za/act/by-law/actor/1980/01", uri.work_uri())
def test_with_long_date(self):
uri = FrbrUri.parse("/akn/za/act/1980-02-01/01")
- assert_equal(uri.country, "za")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980-02-01")
- assert_equal(uri.year, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za/act/1980-02-01/01", uri.work_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980-02-01")
+ self.assertEqual(uri.year, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za/act/1980-02-01/01", uri.work_uri())
def test_with_non_numeric_number(self):
uri = FrbrUri.parse("/akn/za/act/1980/nn")
- assert_equal(uri.country, "za")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "nn")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "nn")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
- assert_equal("/akn/za/act/1980/nn", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/nn", uri.work_uri())
def test_with_work_component(self):
uri = FrbrUri.parse("/akn/za/act/1980/2/!schedule1")
- assert_equal(uri.country, "za")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "2")
- assert_equal(uri.language, "eng")
- assert_equal(uri.work_component, "schedule1")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za/act/1980/2", uri.uri())
- assert_equal("/akn/za/act/1980/2/!schedule1", uri.work_uri())
- assert_equal("/akn/za/act/1980/2/eng/!schedule1", uri.expression_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "2")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.work_component, "schedule1")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za/act/1980/2", uri.uri())
+ self.assertEqual("/akn/za/act/1980/2/!schedule1", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/2/eng/!schedule1", uri.expression_uri())
def test_with_nested_work_components(self):
uri = FrbrUri.parse("/akn/za/act/1980/2/!schedule1/schedule2/schedule3")
- assert_equal(uri.work_component, "schedule1/schedule2/schedule3")
+ self.assertEqual(uri.work_component, "schedule1/schedule2/schedule3")
def test_with_work_component_legacy(self):
uri = FrbrUri.parse("/akn/za/act/1980/2/!schedule1")
- assert_equal(uri.country, "za")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "2")
- assert_equal(uri.language, "eng")
- assert_equal(uri.work_component, "schedule1")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za/act/1980/2", uri.uri())
- assert_equal("/akn/za/act/1980/2/!schedule1", uri.work_uri())
- assert_equal("/akn/za/act/1980/2/eng/!schedule1", uri.expression_uri())
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "2")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.work_component, "schedule1")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za/act/1980/2", uri.uri())
+ self.assertEqual("/akn/za/act/1980/2/!schedule1", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/2/eng/!schedule1", uri.expression_uri())
def test_with_short_work_component(self):
uri = FrbrUri.parse("/akn/za-wc/act/pn/2018/46/!6")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, "wc")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, "pn")
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "2018")
- assert_equal(uri.number, "46")
- assert_equal(uri.language, "eng")
- assert_equal(uri.work_component, "6")
- assert_equal(uri.expression_date, None)
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, "wc")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, "pn")
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "2018")
+ self.assertEqual(uri.number, "46")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.work_component, "6")
+ self.assertEqual(uri.expression_date, None)
uri = FrbrUri.parse("/akn/za-wc/act/2018/46/!6")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, "wc")
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "2018")
- assert_equal(uri.number, "46")
- assert_equal(uri.language, "eng")
- assert_equal(uri.work_component, "6")
- assert_equal(uri.expression_date, None)
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, "wc")
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "2018")
+ self.assertEqual(uri.number, "46")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.work_component, "6")
+ self.assertEqual(uri.expression_date, None)
def test_with_work_component_and_portion(self):
uri = FrbrUri.parse("/akn/za/act/1980/2")
uri.work_component = "main/schedule_1"
uri.portion = "chp_2"
- assert_equal("/akn/za/act/1980/2", uri.uri())
- assert_equal("/akn/za/act/1980/2/!main/schedule_1", uri.work_uri())
- assert_equal("/akn/za/act/1980/2/eng/!main/schedule_1~chp_2", uri.expression_uri())
+ self.assertEqual("/akn/za/act/1980/2", uri.uri())
+ self.assertEqual("/akn/za/act/1980/2/!main/schedule_1", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/2/eng/!main/schedule_1~chp_2", uri.expression_uri())
def test_parse_expression2(self):
uri = FrbrUri.parse("/gh/act/2020/1013/eng@2020-04-03")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, '@2020-04-03')
- assert_equal(uri.number, '1013')
- assert_is_none(uri.subtype)
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, '@2020-04-03')
+ self.assertEqual(uri.number, '1013')
+ self.assertIsNone(uri.subtype)
def test_expression_string_no_language(self):
uri = FrbrUri.parse("/gh/act/2020/1013/")
- assert_equal(uri.language, "eng")
+ self.assertEqual(uri.language, "eng")
uri.language = None
with self.assertRaises(ValueError) as e:
uri.expression_uri()
err = e.exception
- assert_equal(str(err), "Expression URI requires a language.")
+ self.assertEqual(str(err), "Expression URI requires a language.")
def test_parse_expression(self):
uri = FrbrUri.parse("/akn/za/act/1980/02/afr@")
- assert_equal(uri.language, "afr")
- assert_equal(uri.expression_date, '@')
- assert_equal("/akn/za/act/1980/02", uri.work_uri())
- assert_equal("/akn/za/act/1980/02/afr@", uri.expression_uri())
+ self.assertEqual(uri.language, "afr")
+ self.assertEqual(uri.expression_date, '@')
+ self.assertEqual("/akn/za/act/1980/02", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/02/afr@", uri.expression_uri())
uri = FrbrUri.parse("/akn/za/act/1980/02/afr@2014-01-01")
- assert_equal(uri.language, "afr")
- assert_equal(uri.expression_date, "@2014-01-01")
- assert_equal("/akn/za/act/1980/02", uri.work_uri())
- assert_equal("/akn/za/act/1980/02/afr@2014-01-01", uri.expression_uri())
+ self.assertEqual(uri.language, "afr")
+ self.assertEqual(uri.expression_date, "@2014-01-01")
+ self.assertEqual("/akn/za/act/1980/02", uri.work_uri())
+ self.assertEqual("/akn/za/act/1980/02/afr@2014-01-01", uri.expression_uri())
uri = FrbrUri.parse("/akn/za/act/1980/02/afr.html")
- assert_equal(uri.language, "afr")
- assert_equal(uri.format, 'html')
+ self.assertEqual(uri.language, "afr")
+ self.assertEqual(uri.format, 'html')
def test_parse_expression_component_legacy(self):
""" Legacy components without a ! are no longer supported.
@@ -203,21 +202,21 @@ def test_parse_expression_component_legacy(self):
def test_parse_work_component(self):
uri = FrbrUri.parse("/akn/za/act/1980/02/eng/!main")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
- assert_equal(uri.work_component, "main")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+ self.assertEqual(uri.work_component, "main")
uri = FrbrUri.parse("/akn/za/act/1980/02/eng/!main~chp_2")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
- assert_equal(uri.work_component, "main")
- assert_equal(uri.portion, "chp_2")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+ self.assertEqual(uri.work_component, "main")
+ self.assertEqual(uri.portion, "chp_2")
uri = FrbrUri.parse("/akn/za/act/1980/02/eng@/!main~chp_2")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, '@')
- assert_equal(uri.work_component, "main")
- assert_equal(uri.portion, "chp_2")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, '@')
+ self.assertEqual(uri.work_component, "main")
+ self.assertEqual(uri.portion, "chp_2")
def test_parse_expression_date(self):
# A dangling @ indicates the very FIRST expression date, which
@@ -226,48 +225,48 @@ def test_parse_expression_date(self):
# expression date, which is None.
uri = FrbrUri.parse("/akn/za/act/1980/02/eng")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
- assert_equal(uri.expression_uri(), '/akn/za/act/1980/02/eng')
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+ self.assertEqual(uri.expression_uri(), '/akn/za/act/1980/02/eng')
uri = FrbrUri.parse("/akn/za/act/1980/02/eng/!main")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
uri = FrbrUri.parse("/akn/za/act/1980/02/eng@")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, '@')
- assert_equal(uri.expression_uri(), '/akn/za/act/1980/02/eng@')
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, '@')
+ self.assertEqual(uri.expression_uri(), '/akn/za/act/1980/02/eng@')
uri = FrbrUri.parse("/akn/za/act/1980/02/eng@/!main")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, '@')
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, '@')
uri = FrbrUri.parse("/akn/za/act/1980/02/eng:/!main")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, ':')
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, ':')
uri = FrbrUri.parse("/akn/za/act/1980/02/eng:2012-01-01/!main")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, ':2012-01-01')
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, ':2012-01-01')
def test_parse_subtype_numeric_number(self):
# A subtype with a numeric number should not be
# mistaken for an actor
uri = FrbrUri.parse("/akn/za-jhb/act/notice/2007/5319/eng@2007-12-05")
- assert_is_none(uri.actor)
- assert_equal(uri.date, "2007")
- assert_equal(uri.language, "eng")
- assert_equal(uri.number, "5319")
- assert_equal(uri.expression_date, "@2007-12-05")
+ self.assertIsNone(uri.actor)
+ self.assertEqual(uri.date, "2007")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.number, "5319")
+ self.assertEqual(uri.expression_date, "@2007-12-05")
def test_parse_subtype_and_actor(self):
uri = FrbrUri.parse("/akn/za-jhb/act/notice/actor/2007/5319/eng@2007-12-05")
- assert_equal(uri.actor, "actor")
- assert_equal(uri.date, "2007")
- assert_equal(uri.number, "5319")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, "@2007-12-05")
+ self.assertEqual(uri.actor, "actor")
+ self.assertEqual(uri.date, "2007")
+ self.assertEqual(uri.number, "5319")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, "@2007-12-05")
def test_expression_uri(self):
uri = FrbrUri.parse("/akn/za/act/1980/02/eng")
@@ -275,7 +274,7 @@ def test_expression_uri(self):
uri.work_component = 'main'
uri.format = 'html'
- assert_equal("/akn/za/act/1980/02/eng@2014-01-01/!main", uri.expression_uri())
+ self.assertEqual("/akn/za/act/1980/02/eng@2014-01-01/!main", uri.expression_uri())
def test_manifestation_uri(self):
uri = FrbrUri.parse("/akn/za/act/1980/02/eng")
@@ -283,23 +282,23 @@ def test_manifestation_uri(self):
uri.work_component = 'main'
uri.format = 'html'
- assert_equal("/akn/za/act/1980/02/eng@2014-01-01/!main.html", uri.manifestation_uri())
+ self.assertEqual("/akn/za/act/1980/02/eng@2014-01-01/!main.html", uri.manifestation_uri())
def test_simple_prefix(self):
# also recognises akn prefix
uri = FrbrUri.parse("/akn/za/act/1980/01")
- assert_equal(uri.prefix, "akn")
- assert_equal(uri.country, "za")
- assert_equal(uri.locality, None)
- assert_equal(uri.doctype, "act")
- assert_equal(uri.subtype, None)
- assert_equal(uri.actor, None)
- assert_equal(uri.date, "1980")
- assert_equal(uri.number, "01")
- assert_equal(uri.language, "eng")
- assert_equal(uri.expression_date, None)
-
- assert_equal("/akn/za/act/1980/01", uri.work_uri())
+ self.assertEqual(uri.prefix, "akn")
+ self.assertEqual(uri.country, "za")
+ self.assertEqual(uri.locality, None)
+ self.assertEqual(uri.doctype, "act")
+ self.assertEqual(uri.subtype, None)
+ self.assertEqual(uri.actor, None)
+ self.assertEqual(uri.date, "1980")
+ self.assertEqual(uri.number, "01")
+ self.assertEqual(uri.language, "eng")
+ self.assertEqual(uri.expression_date, None)
+
+ self.assertEqual("/akn/za/act/1980/01", uri.work_uri())
def test_akn_prefix(self):
# uses 'akn' prefix as the default when producing one
@@ -312,7 +311,7 @@ def test_akn_prefix(self):
number='31',
actor=None
)
- assert_equal(uri.prefix, "akn")
+ self.assertEqual(uri.prefix, "akn")
# doesn't use 'akn' prefix if explicitly told not to
uri = FrbrUri(
@@ -325,41 +324,41 @@ def test_akn_prefix(self):
number='31',
actor=None
)
- assert_is_none(uri.prefix)
+ self.assertIsNone(uri.prefix)
def test_parse_portion_no_component(self):
uri = FrbrUri.parse("/akn/za/act/2005/5/~sec_5")
- assert_equal(uri.portion, "sec_5")
+ self.assertEqual(uri.portion, "sec_5")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng/~sec_5")
- assert_equal(uri.portion, "sec_5")
+ self.assertEqual(uri.portion, "sec_5")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng@2002-03-01/~sec_5")
- assert_equal(uri.portion, "sec_5")
- assert_equal(uri.expression_uri(), "/akn/za/act/2005/5/eng@2002-03-01/~sec_5")
+ self.assertEqual(uri.portion, "sec_5")
+ self.assertEqual(uri.expression_uri(), "/akn/za/act/2005/5/eng@2002-03-01/~sec_5")
def test_parse_portion_no_component_format(self):
uri = FrbrUri.parse("/akn/za/act/2005/5/~sec_5.html")
- assert_equal(uri.portion, "sec_5")
- assert_equal(uri.format, "html")
+ self.assertEqual(uri.portion, "sec_5")
+ self.assertEqual(uri.format, "html")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng/~sec_5.xml")
- assert_equal(uri.portion, "sec_5")
- assert_equal(uri.format, "xml")
+ self.assertEqual(uri.portion, "sec_5")
+ self.assertEqual(uri.format, "xml")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng@2002-03-01/~sec_5.xml")
- assert_equal(uri.portion, "sec_5")
- assert_equal(uri.format, "xml")
+ self.assertEqual(uri.portion, "sec_5")
+ self.assertEqual(uri.format, "xml")
def test_parse_portion_component(self):
uri = FrbrUri.parse("/akn/za/act/2005/5/!main~sec_5")
- assert_equal(uri.work_component, "main")
- assert_equal(uri.portion, "sec_5")
+ self.assertEqual(uri.work_component, "main")
+ self.assertEqual(uri.portion, "sec_5")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng/!schedule_3~sec_5")
- assert_equal(uri.work_component, "schedule_3")
- assert_equal(uri.portion, "sec_5")
+ self.assertEqual(uri.work_component, "schedule_3")
+ self.assertEqual(uri.portion, "sec_5")
uri = FrbrUri.parse("/akn/za/act/2005/5/eng@2002-03-01/!main~sec_5")
- assert_equal(uri.work_component, "main")
- assert_equal(uri.portion, "sec_5")
+ self.assertEqual(uri.work_component, "main")
+ self.assertEqual(uri.portion, "sec_5")