Skip to content

Commit 6a8a6ba

Browse files
authored
Merge pull request #375 from tirkarthi/fix-assert
Use six.assertRegex instead of assertRegexpMatches for Python 3.11 compatibility.
2 parents b7bab4e + e6f9e3b commit 6a8a6ba

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

tests/test_client.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -768,30 +768,17 @@ def test_build_json_doc_matches_xml(self):
768768
self.assertIsNone(doc_xml.find("*[name='title']"))
769769

770770
def test__build_docs_plain(self):
771-
docs = [{
772-
"id": "doc_1",
773-
"title": "",
774-
"price": 12.59,
775-
"popularity": 10
776-
}]
771+
docs = [{"id": "doc_1", "title": "", "price": 12.59, "popularity": 10}]
777772
solrapi, m, len_message = self.solr._build_docs(docs)
778773
self.assertEqual(solrapi, "JSON")
779774

780775
def test__build_docs_boost(self):
781-
docs = [{
782-
"id": "doc_1",
783-
"title": "",
784-
"price": 12.59,
785-
"popularity": 10
786-
}]
776+
docs = [{"id": "doc_1", "title": "", "price": 12.59, "popularity": 10}]
787777
solrapi, m, len_message = self.solr._build_docs(docs, boost={"title": 10.0})
788778
self.assertEqual(solrapi, "XML")
789779

790780
def test__build_docs_field_updates(self):
791-
docs = [{
792-
"id": "doc_1",
793-
"popularity": 10
794-
}]
781+
docs = [{"id": "doc_1", "popularity": 10}]
795782
solrapi, m, len_message = self.solr._build_docs(
796783
docs, fieldUpdates={"popularity": "inc"}
797784
)

tests/test_cloud.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import unittest
66

7+
import six
8+
79
from pysolr import SolrCloud, SolrError, ZooKeeper, json
810

911
from .test_client import SolrTestCase
@@ -56,16 +58,20 @@ def test_invalid_collection(self):
5658

5759
def test__create_full_url(self):
5860
# Nada.
59-
self.assertRegexpMatches(
60-
self.solr._create_full_url(path=""), r"http://localhost:89../solr/core0$"
61+
six.assertRegex(
62+
self,
63+
self.solr._create_full_url(path=""),
64+
r"http://localhost:89../solr/core0$",
6165
)
6266
# Basic path.
63-
self.assertRegexpMatches(
67+
six.assertRegex(
68+
self,
6469
self.solr._create_full_url(path="pysolr_tests"),
6570
r"http://localhost:89../solr/core0/pysolr_tests$",
6671
)
6772
# Leading slash (& making sure we don't touch the trailing slash).
68-
self.assertRegexpMatches(
73+
six.assertRegex(
74+
self,
6975
self.solr._create_full_url(path="/pysolr_tests/select/?whatever=/"),
7076
r"http://localhost:89../solr/core0/pysolr_tests/select/\?whatever=/",
7177
)

0 commit comments

Comments
 (0)