Repository: django-crispy-forms/django-crispy-forms

Issue:
Tests fail with uni-form errors
Running tox with current master has multiple failing tests. Some seem to be caused by missing uni-form templates.

I'll try to look into this in more detail.


Discussion:

Resolving patch:
diff --git a/crispy_forms/helper.py b/crispy_forms/helper.py
--- a/crispy_forms/helper.py
+++ b/crispy_forms/helper.py
@@ -370,7 +370,7 @@ def get_attributes(self, template_pack=TEMPLATE_PACK):
         }
         
         if template_pack == 'bootstrap4':
-            bootstrap_size_match = re.findall('col-(xl|lg|md|sm)-(\d+)', self.label_class)
+            bootstrap_size_match = re.findall(r'col-(xl|lg|md|sm)-(\d+)', self.label_class)
             if bootstrap_size_match:
                 if template_pack == 'bootstrap4':
                     offset_pattern = 'offset-%s-%s'
@@ -378,7 +378,7 @@ def get_attributes(self, template_pack=TEMPLATE_PACK):
                     offset_pattern = 'col-%s-offset-%s'
                 items['bootstrap_checkbox_offsets'] = [offset_pattern % m for m in bootstrap_size_match]
         else:
-            bootstrap_size_match = re.findall('col-(lg|md|sm|xs)-(\d+)', self.label_class)
+            bootstrap_size_match = re.findall(r'col-(lg|md|sm|xs)-(\d+)', self.label_class)
             if bootstrap_size_match:
                 if template_pack == 'bootstrap4':
                     offset_pattern = 'offset-%s-%s'
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,10 +32,10 @@
         "Operating System :: OS Independent",
         "Programming Language :: JavaScript",
         "Programming Language :: Python :: 2.7",
-        "Programming Language :: Python :: 3.3",
-        "Programming Language :: Python :: 3.4",
         "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
         "Topic :: Software Development :: Libraries :: Python Modules",


Test patch:
diff --git a/crispy_forms/tests/conftest.py b/crispy_forms/tests/conftest.py
--- a/crispy_forms/tests/conftest.py
+++ b/crispy_forms/tests/conftest.py
@@ -32,12 +32,12 @@ def advanced_layout():
 @pytest.fixture(autouse=True, params=('uni_form', 'bootstrap', 'bootstrap3',
                                       'bootstrap4'))
 def template_packs(request, settings):
-    check_template_pack(request._pyfuncitem._obj, request.param)
+    check_template_pack(request.node, request.param)
     settings.CRISPY_TEMPLATE_PACK = request.param
 
 
-def check_template_pack(function, template_pack):
-    if hasattr(function, 'only'):
-        mark = function.only
+def check_template_pack(node, template_pack):
+    mark = node.get_closest_marker('only')
+    if mark:
         if template_pack not in mark.args:
             pytest.skip('Requires %s template pack' % ' or '.join(mark.args))
diff --git a/crispy_forms/tests/test_form_helper.py b/crispy_forms/tests/test_form_helper.py
--- a/crispy_forms/tests/test_form_helper.py
+++ b/crispy_forms/tests/test_form_helper.py
@@ -652,7 +652,7 @@ def test_error_text_inline(settings):
         help_tag_name = 'div'
 
     matches = re.findall(
-        '<span id="error_\d_\w*" class="%s"' % help_class, html, re.MULTILINE
+        r'<span id="error_\d_\w*" class="%s"' % help_class, html, re.MULTILINE
     )
     assert len(matches) == 3
 
@@ -669,7 +669,7 @@ def test_error_text_inline(settings):
         help_tag_name = 'p'
 
     matches = re.findall(
-        '<%s id="error_\d_\w*" class="%s"' % (help_tag_name, help_class),
+        r'<%s id="error_\d_\w*" class="%s"' % (help_tag_name, help_class),
         html,
         re.MULTILINE
     )
diff --git a/crispy_forms/tests/test_layout.py b/crispy_forms/tests/test_layout.py
--- a/crispy_forms/tests/test_layout.py
+++ b/crispy_forms/tests/test_layout.py
@@ -6,7 +6,7 @@
 import django
 from django import forms
 from django.forms.models import formset_factory, modelformset_factory
-from django.shortcuts import render_to_response
+from django.shortcuts import render
 from django.template import Context, Template
 from django.utils.translation import ugettext_lazy as _
 
@@ -555,7 +555,11 @@ def test_keepcontext_context_manager(settings):
     )
     context = {'form': form}
 
-    response = render_to_response('crispy_render_template.html', context)
+    response = render(
+        request=None,
+        template_name='crispy_render_template.html',
+        context=context
+    )
 
     if settings.CRISPY_TEMPLATE_PACK == 'bootstrap':
         assert response.content.count(b'checkbox inline') == 3