Repository: CUNY-CL/wikipron (language: python)

Issue:
`test_american_english_dialect_selection` test breakage
The dialect selector test for English is not working at HEAD (yet again): the "US" selector is also selecting "UK, Generalized Australian" [here](https://en.wiktionary.org/wiki/mocha#Pronunciation). I took a quick look to see if there's been any major change to the pronunciation HTML and I'm not seeing it. 


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2d67d7eb..1d50e1a8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ Unreleased
 
 #### Changed
 
+-   Fixes dialect xpath selector. (\#545)
 -   Fixes table alignment. (\#539)
 -   Repeats big scrape after \#523. (\#536)
 -   Fixes excessive line wrapping. (\#529)
diff --git a/requirements.txt b/requirements.txt
index 18a3c191..24452125 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -9,5 +9,5 @@ requests-html==0.10.0
 requests==2.32.3
 segments==2.2.1
 setuptools==65.6.3
-twine==4.0.1
+twine==5.1.1
 unicodedataplus==15.0.0
diff --git a/src/wikipron/config.py b/src/wikipron/config.py
index 08dd1205..028eb97e 100644
--- a/src/wikipron/config.py
+++ b/src/wikipron/config.py
@@ -30,8 +30,8 @@
 """
 _DIALECT_XPATH_SELECTOR_TEMPLATE = (
     "and\n"
-    '  (span[@class = "ib-content" and a[{dialects_text}]]\n'
-    '   or count(span[@class = "ib-content"]) = 0)'
+    '  (span[contains(@class, "ib-content")]//a[{dialects_text}]\n'
+    '   or count(span[contains(@class, "ib-content")]) = 0)'
 )
 _PHONEMES_REGEX = r"/(.+?)/"
 _PHONES_REGEX = r"\[(.+?)\]"


Test patch:
diff --git a/tests/test_wikipron/test_config.py b/tests/test_wikipron/test_config.py
index ff7bf867..f8970da7 100644
--- a/tests/test_wikipron/test_config.py
+++ b/tests/test_wikipron/test_config.py
@@ -153,8 +153,8 @@ def test_ipa_regex(narrow, ipa_regex, word_in_ipa):
                 "  and\n"
                 '  span[@class = "IPA"]\n'
                 "  and\n"
-                '  (span[@class = "ib-content" and a[text() = "US"]]\n'  # noqa: E501
-                '   or count(span[@class = "ib-content"]) = 0)\n'  # noqa: E501
+                '  (span[contains(@class, "ib-content")]//a[text() = "US"]\n'  # noqa: E501
+                '   or count(span[contains(@class, "ib-content")]) = 0)\n'  # noqa: E501
                 "]\n"
             ),
         ),
@@ -170,8 +170,8 @@ def test_ipa_regex(narrow, ipa_regex, word_in_ipa):
                 "  and\n"
                 '  span[@class = "IPA"]\n'
                 "  and\n"
-                '  (span[@class = "ib-content" and a[text() = "General American" or text() = "US"]]\n'  # noqa: E501
-                '   or count(span[@class = "ib-content"]) = 0)\n'  # noqa: E501
+                '  (span[contains(@class, "ib-content")]//a[text() = "General American" or text() = "US"]\n'  # noqa: E501
+                '   or count(span[contains(@class, "ib-content")]) = 0)\n'  # noqa: E501
                 "]\n"
             ),
         ),