Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use six.assertRegex instead of assertRegexpMatches for Python 3.11 compatibility. #375

Merged
merged 3 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,30 +768,17 @@ def test_build_json_doc_matches_xml(self):
self.assertIsNone(doc_xml.find("*[name='title']"))

def test__build_docs_plain(self):
docs = [{
"id": "doc_1",
"title": "",
"price": 12.59,
"popularity": 10
}]
docs = [{"id": "doc_1", "title": "", "price": 12.59, "popularity": 10}]
solrapi, m, len_message = self.solr._build_docs(docs)
self.assertEqual(solrapi, "JSON")

def test__build_docs_boost(self):
docs = [{
"id": "doc_1",
"title": "",
"price": 12.59,
"popularity": 10
}]
docs = [{"id": "doc_1", "title": "", "price": 12.59, "popularity": 10}]
solrapi, m, len_message = self.solr._build_docs(docs, boost={"title": 10.0})
self.assertEqual(solrapi, "XML")

def test__build_docs_field_updates(self):
docs = [{
"id": "doc_1",
"popularity": 10
}]
docs = [{"id": "doc_1", "popularity": 10}]
solrapi, m, len_message = self.solr._build_docs(
docs, fieldUpdates={"popularity": "inc"}
)
Expand Down
14 changes: 10 additions & 4 deletions tests/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import unittest

import six

from pysolr import SolrCloud, SolrError, ZooKeeper, json

from .test_client import SolrTestCase
Expand Down Expand Up @@ -56,16 +58,20 @@ def test_invalid_collection(self):

def test__create_full_url(self):
# Nada.
self.assertRegexpMatches(
self.solr._create_full_url(path=""), r"http://localhost:89../solr/core0$"
six.assertRegex(
self,
self.solr._create_full_url(path=""),
r"http://localhost:89../solr/core0$",
)
# Basic path.
self.assertRegexpMatches(
six.assertRegex(
self,
self.solr._create_full_url(path="pysolr_tests"),
r"http://localhost:89../solr/core0/pysolr_tests$",
)
# Leading slash (& making sure we don't touch the trailing slash).
self.assertRegexpMatches(
six.assertRegex(
self,
self.solr._create_full_url(path="/pysolr_tests/select/?whatever=/"),
r"http://localhost:89../solr/core0/pysolr_tests/select/\?whatever=/",
)