css-parser 1.1.0__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. {css_parser-1.1.0/src/css_parser.egg-info → css_parser-1.1.2}/PKG-INFO +1 -1
  2. css_parser-1.1.2/css_parser_tests/__init__.py +2 -0
  3. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/basetest.py +24 -30
  4. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_codec.py +52 -52
  5. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_csscharsetrule.py +7 -7
  6. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_csscomment.py +5 -6
  7. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssfontfacerule.py +5 -5
  8. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssimportrule.py +10 -12
  9. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssmediarule.py +7 -7
  10. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssnamespacerule.py +2 -2
  11. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_csspagerule.py +6 -6
  12. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssproperties.py +2 -3
  13. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssrule.py +8 -8
  14. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssrulelist.py +2 -3
  15. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssstyledeclaration.py +7 -9
  16. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssstylerule.py +5 -5
  17. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssstylesheet.py +51 -52
  18. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssunknownrule.py +5 -5
  19. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssutils.py +14 -18
  20. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssutilsimport.py +3 -4
  21. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssvalue.py +0 -1
  22. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssvariablesdeclaration.py +9 -10
  23. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_cssvariablesrule.py +5 -5
  24. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_domimplementation.py +2 -3
  25. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_encutils.py +1 -3
  26. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_errorhandler.py +4 -4
  27. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_helper.py +2 -4
  28. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_marginrule.py +4 -4
  29. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_medialist.py +5 -6
  30. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_mediaquery.py +5 -5
  31. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_parse.py +40 -54
  32. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_prodparser.py +407 -410
  33. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_profiles.py +8 -7
  34. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_properties.py +3 -6
  35. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_property.py +4 -4
  36. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_scripts_csscombine.py +75 -77
  37. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_selector.py +65 -8
  38. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_selectorlist.py +3 -3
  39. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_serialize.py +62 -52
  40. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_settings.py +4 -5
  41. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_stylesheet.py +2 -3
  42. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_tokenize2.py +31 -22
  43. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_util.py +40 -47
  44. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_value.py +6 -6
  45. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/test_x.py +3 -4
  46. {css_parser-1.1.0 → css_parser-1.1.2}/run_tests.py +1 -4
  47. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/__init__.py +20 -30
  48. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/_fetch.py +7 -9
  49. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/_fetchgae.py +8 -8
  50. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/codec.py +4 -9
  51. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/__init__.py +19 -15
  52. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/colors.py +0 -2
  53. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/csscharsetrule.py +12 -19
  54. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/csscomment.py +9 -14
  55. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssfontfacerule.py +8 -17
  56. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssimportrule.py +13 -28
  57. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssmediarule.py +14 -28
  58. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssnamespacerule.py +12 -22
  59. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/csspagerule.py +14 -32
  60. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssproperties.py +4 -3
  61. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssrule.py +15 -24
  62. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssrulelist.py +0 -2
  63. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssstyledeclaration.py +21 -32
  64. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssstylerule.py +12 -25
  65. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssstylesheet.py +19 -33
  66. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssunknownrule.py +11 -17
  67. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssvalue.py +56 -85
  68. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssvariablesdeclaration.py +13 -18
  69. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/cssvariablesrule.py +9 -20
  70. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/marginrule.py +10 -16
  71. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/property.py +47 -70
  72. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/selector.py +105 -67
  73. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/selectorlist.py +9 -15
  74. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/css/value.py +41 -62
  75. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/cssproductions.py +4 -5
  76. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/encutils/__init__.py +29 -40
  77. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/errorhandler.py +6 -10
  78. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/helper.py +9 -14
  79. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/parse.py +6 -12
  80. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/prodparser.py +27 -40
  81. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/profiles.py +30 -32
  82. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/sac.py +30 -37
  83. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/script.py +36 -46
  84. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/scripts/__init__.py +1 -1
  85. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/scripts/csscapture.py +6 -7
  86. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/scripts/csscombine.py +2 -3
  87. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/scripts/cssparse.py +3 -4
  88. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/serialize.py +43 -45
  89. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/settings.py +1 -3
  90. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/stylesheets/__init__.py +0 -1
  91. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/stylesheets/medialist.py +6 -10
  92. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/stylesheets/mediaquery.py +8 -10
  93. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/stylesheets/stylesheet.py +1 -2
  94. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/stylesheets/stylesheetlist.py +0 -1
  95. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/tokenize2.py +12 -15
  96. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser/util.py +27 -36
  97. {css_parser-1.1.0 → css_parser-1.1.2/src/css_parser.egg-info}/PKG-INFO +1 -1
  98. css_parser-1.1.0/css_parser_tests/__init__.py +0 -3
  99. {css_parser-1.1.0 → css_parser-1.1.2}/COPYING +0 -0
  100. {css_parser-1.1.0 → css_parser-1.1.2}/COPYING.LESSER +0 -0
  101. {css_parser-1.1.0 → css_parser-1.1.2}/MANIFEST.in +0 -0
  102. {css_parser-1.1.0 → css_parser-1.1.2}/README.md +0 -0
  103. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/096.css +0 -0
  104. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/097.css +0 -0
  105. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1.css +0 -0
  106. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1ascii.css +0 -0
  107. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1import.css +0 -0
  108. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1inherit-ascii.css +0 -0
  109. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1inherit-iso.css +0 -0
  110. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1inherit-utf8.css +0 -0
  111. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/1utf.css +0 -0
  112. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/2inherit-iso.css +0 -0
  113. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/2resolve.css +0 -0
  114. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/acid2.css +0 -0
  115. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/all.css +0 -0
  116. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/atrule.css +0 -0
  117. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/bad.css +0 -0
  118. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/basic.css +0 -0
  119. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/bundle.css +0 -0
  120. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/cases.css +0 -0
  121. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/csscombine-1.css +0 -0
  122. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/csscombine-2.css +0 -0
  123. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/csscombine-proxy.css +0 -0
  124. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/cthedot_default.css +0 -0
  125. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/default_html4.css +0 -0
  126. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/hacks.css +0 -0
  127. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/html.css +0 -0
  128. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/html20.css +0 -0
  129. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/html40.css +0 -0
  130. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/import/import-impossible.css +0 -0
  131. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/import/import2.css +0 -0
  132. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/import.css +0 -0
  133. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/import3.css +0 -0
  134. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/ll.css +0 -0
  135. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/ll2.css +0 -0
  136. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/multiple-values.css +0 -0
  137. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/page_test.css +0 -0
  138. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/sample_5.css +0 -0
  139. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/sample_7.css +0 -0
  140. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/simple.css +0 -0
  141. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/single-color.css +0 -0
  142. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/slashcode.css +0 -0
  143. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/t-HACKS.css +0 -0
  144. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/test-unicode.css +0 -0
  145. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/test.css +0 -0
  146. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/tigris.css +0 -0
  147. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/tigris2.css +0 -0
  148. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/u_simple.css +0 -0
  149. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/v_simple.css +0 -0
  150. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/var/start.css +0 -0
  151. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/var/use.css +0 -0
  152. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/var/vars.css +0 -0
  153. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/var/vars2.css +0 -0
  154. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/vars.css +0 -0
  155. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/varsimport.css +0 -0
  156. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/xhtml2.css +0 -0
  157. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/xhtml22.css +0 -0
  158. {css_parser-1.1.0 → css_parser-1.1.2}/css_parser_tests/sheets/yuck.css +0 -0
  159. {css_parser-1.1.0 → css_parser-1.1.2}/pyproject.toml +0 -0
  160. {css_parser-1.1.0 → css_parser-1.1.2}/setup.cfg +0 -0
  161. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser.egg-info/SOURCES.txt +0 -0
  162. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser.egg-info/dependency_links.txt +0 -0
  163. {css_parser-1.1.0 → css_parser-1.1.2}/src/css_parser.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: css-parser
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: A CSS Cascading Style Sheets library for Python
5
5
  Author-email: Various People <redacted@anonymous.net>
6
6
  License-Expression: LGPL-3.0-or-later
@@ -0,0 +1,2 @@
1
+ """css_parser unittests"""
2
+
@@ -1,4 +1,3 @@
1
- from __future__ import absolute_import, print_function, unicode_literals
2
1
 
3
2
  import logging
4
3
  import os
@@ -124,8 +123,8 @@ class BaseTestCase(unittest.TestCase):
124
123
  exc_pattern = None
125
124
 
126
125
  argv = [repr(a) for a in args]\
127
- + ["%s=%r" % (k, v) for k, v in kwargs.items()]
128
- callsig = "%s(%s)" % (callable.__name__, ", ".join(argv))
126
+ + [f"{k}={v!r}" for k, v in kwargs.items()]
127
+ callsig = "{}({})".format(callable.__name__, ", ".join(argv))
129
128
 
130
129
  try:
131
130
  callable(*args, **kwargs)
@@ -134,21 +133,18 @@ class BaseTestCase(unittest.TestCase):
134
133
  self.assertEqual(
135
134
  exc.args,
136
135
  exc_args,
137
- '%s raised %s with unexpected args: expected=%r, actual=%r' % (callsig, exc.__class__, exc_args, exc.args)
136
+ f'{callsig} raised {exc.__class__} with unexpected args: expected={exc_args!r}, actual={exc.args!r}'
138
137
  )
139
138
  if exc_pattern is not None:
140
139
  self.assertTrue(exc_pattern.search(str(exc)),
141
- "%s raised %s, but the exception "
142
- "does not match '%s': %r"
143
- % (callsig, exc.__class__, exc_pattern.pattern,
144
- str(exc)))
145
- except Exception:
140
+ f"{callsig} raised {exc.__class__}, but the exception "
141
+ f"does not match '{exc_pattern.pattern}': {str(exc)!r}")
142
+ except Exception: # noqa: BLE001 any other exception is a test failure
146
143
  exc_info = sys.exc_info()
147
- self.fail("%s raised an unexpected exception type: "
148
- "expected=%s, actual=%s"
149
- % (callsig, exception, exc_info[0]))
144
+ self.fail(f"{callsig} raised an unexpected exception type: "
145
+ f"expected={exception}, actual={exc_info[0]}")
150
146
  else:
151
- self.fail("%s did not raise %s" % (callsig, exception))
147
+ self.fail(f"{callsig} did not raise {exception}")
152
148
 
153
149
  def _assertRaisesMsgSubstring(self, excClass, msg, substring_match, callableObj, *args, **kwargs):
154
150
  try:
@@ -164,16 +160,14 @@ class BaseTestCase(unittest.TestCase):
164
160
  else:
165
161
  # Message provided, and it didn't match: fail!
166
162
  raise self.failureException(
167
- "Right exception, wrong message: got '%s' instead of '%s'" %
168
- (excMsg, msg))
163
+ f"Right exception, wrong message: got '{excMsg}' instead of '{msg}'")
169
164
  else:
170
165
  if hasattr(excClass, '__name__'):
171
166
  excName = excClass.__name__
172
167
  else:
173
168
  excName = str(excClass)
174
169
  raise self.failureException(
175
- "Expected to raise %s, didn't get an exception at all" %
176
- excName
170
+ f"Expected to raise {excName}, didn't get an exception at all"
177
171
  )
178
172
 
179
173
  def assertRaisesMsg(self, excClass, msg, callableObj, *args, **kwargs):
@@ -207,7 +201,7 @@ class BaseTestCase(unittest.TestCase):
207
201
  # parses with self.p and checks att of result
208
202
  for test, expected in tests.items():
209
203
  if debug:
210
- print(('"%s"' % test))
204
+ print(f'"{test}"')
211
205
  s = p.parseString(test)
212
206
  if expected is None:
213
207
  expected = test
@@ -221,14 +215,14 @@ class BaseTestCase(unittest.TestCase):
221
215
  p = css_parser.CSSParser(raiseExceptions=raising)
222
216
  for test, expected in tests.items():
223
217
  if debug:
224
- print(('"%s"' % test))
218
+ print(f'"{test}"')
225
219
  self.assertRaises(expected, p.parseString, test)
226
220
 
227
221
  def do_equal_r(self, tests, att='cssText', debug=False):
228
222
  # sets attribute att of self.r and asserts Equal
229
223
  for test, expected in tests.items():
230
224
  if debug:
231
- print(('"%s"' % test))
225
+ print(f'"{test}"')
232
226
  self.r.__setattr__(att, test)
233
227
  if expected is None:
234
228
  expected = test
@@ -238,14 +232,14 @@ class BaseTestCase(unittest.TestCase):
238
232
  # sets self.r and asserts raise
239
233
  for test, expected in tests.items():
240
234
  if debug:
241
- print(('"%s"' % test))
235
+ print(f'"{test}"')
242
236
  self.assertRaises(expected, self.r.__getattribute__(att), test)
243
237
 
244
238
  def do_raise_r_list(self, tests, err, att='_setCssText', debug=False):
245
239
  # sets self.r and asserts raise
246
240
  for test in tests:
247
241
  if debug:
248
- print(('"%s"' % test))
242
+ print(f'"{test}"')
249
243
  self.assertRaises(err, self.r.__getattribute__(att), test)
250
244
 
251
245
 
@@ -280,25 +274,25 @@ class GenerateTests(type):
280
274
  cases = aobj.cases
281
275
  for case_num, case in enumerate(cases):
282
276
  stringed_case = cls.make_case_repr(case)
283
- case_name = "%s_%s_%s" % (test_name, case_num, stringed_case)
277
+ case_name = f"{test_name}_{case_num}_{stringed_case}"
284
278
  # Force the closure binding
285
279
 
286
280
  def make_wrapper(case=case, aobj=aobj):
287
281
  def wrapper(self):
288
282
  aobj(self, *case)
289
283
  return wrapper
290
- wrapper = make_wrapper()
291
- wrapper.__name__ = str(case_name)
292
- wrapper.__doc__ = "%s(%s)" % (test_name,
293
- ", ".join(map(repr, case)))
284
+ test_func = make_wrapper()
285
+ test_func.__name__ = str(case_name)
286
+ test_func.__doc__ = "{}({})".format(test_name,
287
+ ", ".join(map(repr, case)))
294
288
  if aobj.__doc__ is not None:
295
- wrapper.__doc__ += "\n\n" + aobj.__doc__
296
- new_attrs[case_name] = wrapper
289
+ test_func.__doc__ += "\n\n" + aobj.__doc__
290
+ new_attrs[case_name] = test_func
297
291
  return type(name, bases, new_attrs)
298
292
 
299
293
  @classmethod
300
294
  def make_case_repr(cls, case):
301
- if isinstance(case, type('')):
295
+ if isinstance(case, str):
302
296
  value = case
303
297
  else:
304
298
  try:
@@ -17,13 +17,13 @@ else:
17
17
  haveutf32 = True
18
18
 
19
19
 
20
- class Queue(object):
20
+ class Queue:
21
21
  """
22
22
  queue: write bytes at one end, read bytes from the other end
23
23
  """
24
24
 
25
25
  def __init__(self):
26
- self._buffer = "".encode()
26
+ self._buffer = b""
27
27
 
28
28
  def write(self, chars):
29
29
  # TODO ???
@@ -37,7 +37,7 @@ class Queue(object):
37
37
  def read(self, size=-1):
38
38
  if size < 0:
39
39
  s = self._buffer
40
- self._buffer = "".encode()
40
+ self._buffer = b""
41
41
  return s
42
42
  else:
43
43
  s = self._buffer[:size]
@@ -49,54 +49,54 @@ class CodecTestCase(unittest.TestCase):
49
49
 
50
50
  def test_detectencoding_str(self):
51
51
  "codec.detectencoding_str()"
52
- self.assertEqual(codec.detectencoding_str(''.encode()), (None, False))
52
+ self.assertEqual(codec.detectencoding_str(b''), (None, False))
53
53
  self.assertEqual(codec.detectencoding_str('\xef'.encode('latin1')), (None, False))
54
- self.assertEqual(codec.detectencoding_str('\xef\x33'.encode("utf-8")), ("utf-8", False))
55
- self.assertEqual(codec.detectencoding_str('\xc3\xaf3'.encode("utf-8")), ("utf-8", False))
54
+ self.assertEqual(codec.detectencoding_str('\xef\x33'.encode()), ("utf-8", False))
55
+ self.assertEqual(codec.detectencoding_str('\xc3\xaf3'.encode()), ("utf-8", False))
56
56
  self.assertEqual(codec.detectencoding_str('\xef\xbb'.encode("latin1")), (None, False))
57
- self.assertEqual(codec.detectencoding_str('\xef\xbb\x33'.encode("utf-8")), ("utf-8", False))
57
+ self.assertEqual(codec.detectencoding_str('\xef\xbb\x33'.encode()), ("utf-8", False))
58
58
  self.assertEqual(codec.detectencoding_str('\xef\xbb\xbf'.encode("utf-8-sig")), ("utf-8-sig", True))
59
59
  self.assertEqual(codec.detectencoding_str('\xff'.encode("latin1")), (None, False))
60
- self.assertEqual(codec.detectencoding_str('\xff\x33'.encode("utf-8")), ("utf-8", False))
60
+ self.assertEqual(codec.detectencoding_str('\xff\x33'.encode()), ("utf-8", False))
61
61
  self.assertEqual(codec.detectencoding_str('\xff\xfe'.encode("latin1")), (None, False))
62
62
  self.assertEqual(codec.detectencoding_str('\xff\xfe\x33'.encode("utf-16")), ("utf-16", True))
63
63
  self.assertEqual(codec.detectencoding_str('\xff\xfe\x00'.encode("latin1")), (None, False))
64
64
  self.assertEqual(codec.detectencoding_str('\xff\xfe\x00\x33'.encode("utf-16")), ("utf-16", True))
65
65
  if haveutf32:
66
66
  self.assertEqual(codec.detectencoding_str('\xff\xfe\x00\x00'.encode("utf-32")), ("utf-32", True))
67
- self.assertEqual(codec.detectencoding_str('\x00'.encode()), (None, False))
68
- self.assertEqual(codec.detectencoding_str('\x00\x33'.encode()), ("utf-8", False))
69
- self.assertEqual(codec.detectencoding_str('\x00\x00'.encode()), (None, False))
70
- self.assertEqual(codec.detectencoding_str('\x00\x00\x33'.encode()), ("utf-8", False))
67
+ self.assertEqual(codec.detectencoding_str(b'\x00'), (None, False))
68
+ self.assertEqual(codec.detectencoding_str(b'\x00\x33'), ("utf-8", False))
69
+ self.assertEqual(codec.detectencoding_str(b'\x00\x00'), (None, False))
70
+ self.assertEqual(codec.detectencoding_str(b'\x00\x00\x33'), ("utf-8", False))
71
71
  self.assertEqual(codec.detectencoding_str('\x00\x00\xfe'.encode('latin1')), (None, False))
72
- self.assertEqual(codec.detectencoding_str('\x00\x00\x00\x33'.encode()), ("utf-8", False))
72
+ self.assertEqual(codec.detectencoding_str(b'\x00\x00\x00\x33'), ("utf-8", False))
73
73
  if haveutf32:
74
- self.assertEqual(codec.detectencoding_str('\x00\x00\x00@'.encode()), ("utf-32-be", False))
74
+ self.assertEqual(codec.detectencoding_str(b'\x00\x00\x00@'), ("utf-32-be", False))
75
75
  self.assertEqual(codec.detectencoding_str('\x00\x00\xfe\xff'.encode('utf-32')), ("utf-32", True))
76
- self.assertEqual(codec.detectencoding_str('@'.encode()), (None, False))
77
- self.assertEqual(codec.detectencoding_str('@\x33'.encode()), ("utf-8", False))
78
- self.assertEqual(codec.detectencoding_str('@\x00'.encode()), (None, False))
79
- self.assertEqual(codec.detectencoding_str('@\x00\x33'.encode()), ("utf-8", False))
80
- self.assertEqual(codec.detectencoding_str('@\x00\x00'.encode()), (None, False))
81
- self.assertEqual(codec.detectencoding_str('@\x00\x00\x33'.encode()), ("utf-8", False))
76
+ self.assertEqual(codec.detectencoding_str(b'@'), (None, False))
77
+ self.assertEqual(codec.detectencoding_str(b'@\x33'), ("utf-8", False))
78
+ self.assertEqual(codec.detectencoding_str(b'@\x00'), (None, False))
79
+ self.assertEqual(codec.detectencoding_str(b'@\x00\x33'), ("utf-8", False))
80
+ self.assertEqual(codec.detectencoding_str(b'@\x00\x00'), (None, False))
81
+ self.assertEqual(codec.detectencoding_str(b'@\x00\x00\x33'), ("utf-8", False))
82
82
  if haveutf32:
83
- self.assertEqual(codec.detectencoding_str('@\x00\x00\x00'.encode()), ("utf-32-le", False))
84
- self.assertEqual(codec.detectencoding_str('@c'.encode()), (None, False))
85
- self.assertEqual(codec.detectencoding_str('@ch'.encode()), (None, False))
86
- self.assertEqual(codec.detectencoding_str('@cha'.encode()), (None, False))
87
- self.assertEqual(codec.detectencoding_str('@char'.encode()), (None, False))
88
- self.assertEqual(codec.detectencoding_str('@chars'.encode()), (None, False))
89
- self.assertEqual(codec.detectencoding_str('@charse'.encode()), (None, False))
90
- self.assertEqual(codec.detectencoding_str('@charset'.encode()), (None, False))
91
- self.assertEqual(codec.detectencoding_str('@charset '.encode()), (None, False))
92
- self.assertEqual(codec.detectencoding_str('@charset "'.encode()), (None, False))
93
- self.assertEqual(codec.detectencoding_str('@charset "x'.encode()), (None, False))
94
- self.assertEqual(codec.detectencoding_str('@charset ""'.encode()), ("", True))
95
- self.assertEqual(codec.detectencoding_str('@charset "x"'.encode()), ("x", True))
96
- self.assertEqual(codec.detectencoding_str("@".encode(), False), (None, False))
97
- self.assertEqual(codec.detectencoding_str("@".encode(), True), ("utf-8", False))
98
- self.assertEqual(codec.detectencoding_str("@c".encode(), False), (None, False))
99
- self.assertEqual(codec.detectencoding_str("@c".encode(), True), ("utf-8", False))
83
+ self.assertEqual(codec.detectencoding_str(b'@\x00\x00\x00'), ("utf-32-le", False))
84
+ self.assertEqual(codec.detectencoding_str(b'@c'), (None, False))
85
+ self.assertEqual(codec.detectencoding_str(b'@ch'), (None, False))
86
+ self.assertEqual(codec.detectencoding_str(b'@cha'), (None, False))
87
+ self.assertEqual(codec.detectencoding_str(b'@char'), (None, False))
88
+ self.assertEqual(codec.detectencoding_str(b'@chars'), (None, False))
89
+ self.assertEqual(codec.detectencoding_str(b'@charse'), (None, False))
90
+ self.assertEqual(codec.detectencoding_str(b'@charset'), (None, False))
91
+ self.assertEqual(codec.detectencoding_str(b'@charset '), (None, False))
92
+ self.assertEqual(codec.detectencoding_str(b'@charset "'), (None, False))
93
+ self.assertEqual(codec.detectencoding_str(b'@charset "x'), (None, False))
94
+ self.assertEqual(codec.detectencoding_str(b'@charset ""'), ("", True))
95
+ self.assertEqual(codec.detectencoding_str(b'@charset "x"'), ("x", True))
96
+ self.assertEqual(codec.detectencoding_str(b"@", False), (None, False))
97
+ self.assertEqual(codec.detectencoding_str(b"@", True), ("utf-8", False))
98
+ self.assertEqual(codec.detectencoding_str(b"@c", False), (None, False))
99
+ self.assertEqual(codec.detectencoding_str(b"@c", True), ("utf-8", False))
100
100
 
101
101
  def test_detectencoding_unicode(self):
102
102
  "codec.detectencoding_unicode()"
@@ -131,22 +131,22 @@ class CodecTestCase(unittest.TestCase):
131
131
  outputencoding = "utf-8"
132
132
  # Check stateless decoder with encoding autodetection
133
133
  d = codecs.getdecoder("css")
134
- self.assertEqual(d(input.encode(encoding))[0], input.replace('"x"', '"%s"' % outputencoding))
134
+ self.assertEqual(d(input.encode(encoding))[0], input.replace('"x"', f'"{outputencoding}"'))
135
135
 
136
136
  # Check stateless decoder with specified encoding
137
137
  self.assertEqual(d(input.encode(encoding), encoding=encoding)[
138
- 0], input.replace('"x"', '"%s"' % outputencoding))
138
+ 0], input.replace('"x"', f'"{outputencoding}"'))
139
139
 
140
140
  if hasattr(codec, "getincrementaldecoder"):
141
141
  # Check incremental decoder with encoding autodetection
142
142
  id = codecs.getincrementaldecoder("css")()
143
143
  self.assertEqual("".join(id.iterdecode(input.encode(encoding))),
144
- input.replace('"x"', '"%s"' % outputencoding))
144
+ input.replace('"x"', f'"{outputencoding}"'))
145
145
 
146
146
  # Check incremental decoder with specified encoding
147
147
  id = codecs.getincrementaldecoder("css")(encoding=encoding)
148
148
  self.assertEqual("".join(id.iterdecode(input.encode(encoding))),
149
- input.replace('"x"', '"%s"' % outputencoding))
149
+ input.replace('"x"', f'"{outputencoding}"'))
150
150
 
151
151
  # Check stream reader with encoding autodetection
152
152
  q = Queue()
@@ -156,7 +156,7 @@ class CodecTestCase(unittest.TestCase):
156
156
  for c in input.encode(encoding):
157
157
  q.write(c)
158
158
  result.append(sr.read())
159
- self.assertEqual("".join(result), input.replace('"x"', '"%s"' % outputencoding))
159
+ self.assertEqual("".join(result), input.replace('"x"', f'"{outputencoding}"'))
160
160
 
161
161
  # Check stream reader with specified encoding
162
162
  q = Queue()
@@ -165,7 +165,7 @@ class CodecTestCase(unittest.TestCase):
165
165
  for c in input.encode(encoding):
166
166
  q.write(c)
167
167
  result.append(sr.read())
168
- self.assertEqual("".join(result), input.replace('"x"', '"%s"' % outputencoding))
168
+ self.assertEqual("".join(result), input.replace('"x"', f'"{outputencoding}"'))
169
169
 
170
170
  # Autodetectable encodings
171
171
  checkauto("utf-8-sig")
@@ -223,7 +223,7 @@ class CodecTestCase(unittest.TestCase):
223
223
  checkdecl("cp1252")
224
224
 
225
225
  # No recursion
226
- self.assertRaises(ValueError, '@charset "css";div{}'.encode().decode, "css")
226
+ self.assertRaises(ValueError, b'@charset "css";div{}'.decode, "css")
227
227
 
228
228
  def test_encoder(self):
229
229
  "codec.encoder"
@@ -234,8 +234,8 @@ class CodecTestCase(unittest.TestCase):
234
234
 
235
235
  # Check stateless encoder with encoding autodetection
236
236
  e = codecs.getencoder("css")
237
- inputdecl = input.replace('"x"', '"%s"' % encoding)
238
- outputdecl = input.replace('"x"', '"%s"' % outputencoding)
237
+ inputdecl = input.replace('"x"', f'"{encoding}"')
238
+ outputdecl = input.replace('"x"', f'"{outputencoding}"')
239
239
  self.assertEqual(e(inputdecl)[0].decode(encoding), outputdecl)
240
240
 
241
241
  # Check stateless encoder with specified encoding
@@ -255,14 +255,14 @@ class CodecTestCase(unittest.TestCase):
255
255
  sw = codecs.getwriter("css")(q)
256
256
  for c in inputdecl: # .encode(outputencoding): # TODO: .encode()???
257
257
  sw.write(c)
258
- self.assertEqual(q.read().decode(encoding), input.replace('"x"', '"%s"' % outputencoding))
258
+ self.assertEqual(q.read().decode(encoding), input.replace('"x"', f'"{outputencoding}"'))
259
259
 
260
260
  # Check stream writer with specified encoding
261
261
  q = Queue()
262
262
  sw = codecs.getwriter("css")(q, encoding=encoding)
263
263
  for c in input:
264
264
  sw.write(c)
265
- self.assertEqual(q.read().decode(encoding), input.replace('"x"', '"%s"' % outputencoding))
265
+ self.assertEqual(q.read().decode(encoding), input.replace('"x"', f'"{outputencoding}"'))
266
266
 
267
267
  # Autodetectable encodings
268
268
  check("utf-8-sig")
@@ -315,22 +315,22 @@ class CodecTestCase(unittest.TestCase):
315
315
  # output = u'@charset "utf-8"; \xff'
316
316
  # self.assertEqual(d(input, encoding="iso-8859-1", force=False), output)
317
317
 
318
- input = '@charset "utf-8"; \xff'.encode('utf-8')
318
+ input = '@charset "utf-8"; \xff'.encode()
319
319
  output = '@charset "utf-8"; \xff'
320
320
  self.assertEqual(d(input), output)
321
321
 
322
322
  #input = b'@charset "utf-8"; \xc3\xbf'
323
- input = '@charset "utf-8"; \xff'.encode('utf-8')
323
+ input = '@charset "utf-8"; \xff'.encode()
324
324
  output = '@charset "iso-8859-1"; \xc3\xbf'
325
325
  self.assertEqual(d(input, encoding="iso-8859-1", force=True), output)
326
326
 
327
327
  #input = b'\xc3\xbf'
328
- input = '\xff'.encode('utf-8')
328
+ input = '\xff'.encode()
329
329
  output = '\xc3\xbf'
330
330
  self.assertEqual(d(input, encoding="iso-8859-1", force=True), output)
331
331
 
332
332
  #input = b'@charset "utf-8"; \xc3\xbf'
333
- input = '@charset "utf-8"; \xff'.encode('utf-8')
333
+ input = '@charset "utf-8"; \xff'.encode()
334
334
  output = '@charset "utf-8"; \xff'
335
335
  self.assertEqual(d(input, encoding="iso-8859-1", force=False), output)
336
336
 
@@ -1,17 +1,17 @@
1
1
  """Testcases for css_parser.css.CSSCharsetRule"""
2
2
 
3
- from __future__ import absolute_import
4
- from __future__ import unicode_literals
5
3
  import re
6
4
  import xml.dom
7
- from . import test_cssrule
5
+
8
6
  import css_parser.css
9
7
 
8
+ from . import test_cssrule
9
+
10
10
 
11
11
  class CSSCharsetRuleTestCase(test_cssrule.CSSRuleTestCase):
12
12
 
13
13
  def setUp(self):
14
- super(CSSCharsetRuleTestCase, self).setUp()
14
+ super().setUp()
15
15
  self.r = css_parser.css.CSSCharsetRule()
16
16
  self.rRO = css_parser.css.CSSCharsetRule(readonly=True)
17
17
  self.r_type = css_parser.css.CSSCharsetRule.CHARSET_RULE
@@ -19,7 +19,7 @@ class CSSCharsetRuleTestCase(test_cssrule.CSSRuleTestCase):
19
19
 
20
20
  def test_init(self):
21
21
  "CSSCharsetRule.__init__()"
22
- super(CSSCharsetRuleTestCase, self).test_init()
22
+ super().test_init()
23
23
  self.assertEqual(None, self.r.encoding)
24
24
  self.assertEqual('', self.r.cssText)
25
25
 
@@ -39,7 +39,7 @@ class CSSCharsetRuleTestCase(test_cssrule.CSSRuleTestCase):
39
39
  else:
40
40
  self.assertEqual(enc.lower(), r.encoding)
41
41
  self.assertEqual(
42
- '@charset "%s";' % enc.lower(), r.cssText)
42
+ f'@charset "{enc.lower()}";', r.cssText)
43
43
 
44
44
  for enc in (' ascii ', ' ascii', 'ascii '):
45
45
  self.assertRaisesEx(xml.dom.SyntaxErr,
@@ -57,7 +57,7 @@ class CSSCharsetRuleTestCase(test_cssrule.CSSRuleTestCase):
57
57
  self.r.encoding = enc
58
58
  self.assertEqual(enc.lower(), self.r.encoding)
59
59
  self.assertEqual(
60
- '@charset "%s";' % enc.lower(), self.r.cssText)
60
+ f'@charset "{enc.lower()}";', self.r.cssText)
61
61
 
62
62
  for enc in (None, ' ascii ', ' ascii', 'ascii '):
63
63
  self.assertRaisesEx(xml.dom.SyntaxErr,
@@ -1,17 +1,16 @@
1
- # -*- coding: utf-8 -*-
2
1
  """Testcases for css_parser.css.CSSComment"""
3
2
 
4
- from __future__ import absolute_import
5
- from __future__ import unicode_literals
6
3
  import xml
7
- from . import test_cssrule
4
+
8
5
  import css_parser.css
9
6
 
7
+ from . import test_cssrule
8
+
10
9
 
11
10
  class CSSCommentTestCase(test_cssrule.CSSRuleTestCase):
12
11
 
13
12
  def setUp(self):
14
- super(CSSCommentTestCase, self).setUp()
13
+ super().setUp()
15
14
  self.r = css_parser.css.CSSComment()
16
15
  self.rRO = css_parser.css.CSSComment(readonly=True)
17
16
  self.r_type = css_parser.css.CSSComment.COMMENT
@@ -19,7 +18,7 @@ class CSSCommentTestCase(test_cssrule.CSSRuleTestCase):
19
18
 
20
19
  def test_init(self):
21
20
  "CSSComment.type and init"
22
- super(CSSCommentTestCase, self).test_init()
21
+ super().test_init()
23
22
 
24
23
  def test_csstext(self):
25
24
  "CSSComment.cssText"
@@ -1,16 +1,16 @@
1
1
  """Testcases for css_parser.css.CSSFontFaceRule"""
2
2
 
3
- from __future__ import absolute_import
4
- from __future__ import unicode_literals
5
3
  import xml.dom
6
- from . import test_cssrule
4
+
7
5
  import css_parser
8
6
 
7
+ from . import test_cssrule
8
+
9
9
 
10
10
  class CSSFontFaceRuleTestCase(test_cssrule.CSSRuleTestCase):
11
11
 
12
12
  def setUp(self):
13
- super(CSSFontFaceRuleTestCase, self).setUp()
13
+ super().setUp()
14
14
  self.r = css_parser.css.CSSFontFaceRule()
15
15
  self.rRO = css_parser.css.CSSFontFaceRule(readonly=True)
16
16
  self.r_type = css_parser.css.CSSFontFaceRule.FONT_FACE_RULE
@@ -18,7 +18,7 @@ class CSSFontFaceRuleTestCase(test_cssrule.CSSRuleTestCase):
18
18
 
19
19
  def test_init(self):
20
20
  "CSSFontFaceRule.__init__()"
21
- super(CSSFontFaceRuleTestCase, self).test_init()
21
+ super().test_init()
22
22
 
23
23
  r = css_parser.css.CSSFontFaceRule()
24
24
  self.assertIsInstance(r.style, css_parser.css.CSSStyleDeclaration)
@@ -1,18 +1,16 @@
1
1
  """Testcases for css_parser.css.CSSImportRule"""
2
2
 
3
- from __future__ import absolute_import
4
- from __future__ import unicode_literals
5
3
  import xml.dom
6
- from . import test_cssrule
4
+
7
5
  import css_parser
8
6
 
9
- from . import basetest
7
+ from . import basetest, test_cssrule
10
8
 
11
9
 
12
10
  class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
13
11
 
14
12
  def setUp(self):
15
- super(CSSImportRuleTestCase, self).setUp()
13
+ super().setUp()
16
14
  self.r = css_parser.css.CSSImportRule()
17
15
  self.rRO = css_parser.css.CSSImportRule(readonly=True)
18
16
  self.r_type = css_parser.css.CSSImportRule.IMPORT_RULE
@@ -20,7 +18,7 @@ class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
20
18
 
21
19
  def test_init(self):
22
20
  "CSSImportRule.__init__()"
23
- super(CSSImportRuleTestCase, self).test_init()
21
+ super().test_init()
24
22
 
25
23
  # no init param
26
24
  self.assertEqual(None, self.r.href)
@@ -227,12 +225,12 @@ class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
227
225
  sheet = parser.parseString('@import "http://example.com/yes" "name"')
228
226
 
229
227
  r = sheet.cssRules[0]
230
- self.assertEqual('/**/'.encode(), r.styleSheet.cssText)
228
+ self.assertEqual(b'/**/', r.styleSheet.cssText)
231
229
  self.assertEqual(True, r.hrefFound)
232
230
  self.assertEqual('name', r.name)
233
231
 
234
232
  r.cssText = '@import url(http://example.com/none) "name2";'
235
- self.assertEqual(''.encode(), r.styleSheet.cssText)
233
+ self.assertEqual(b'', r.styleSheet.cssText)
236
234
  self.assertEqual(False, r.hrefFound)
237
235
  self.assertEqual('name2', r.name)
238
236
 
@@ -360,7 +358,7 @@ class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
360
358
  self.assertEqual(ir.styleSheet.parentStyleSheet, None) # sheet
361
359
  self.assertEqual(ir.styleSheet.title, 'title')
362
360
  self.assertEqual(ir.styleSheet.cssText,
363
- '@charset "ascii";\n@import "level2/css.css" "title2";'.encode())
361
+ b'@charset "ascii";\n@import "level2/css.css" "title2";')
364
362
 
365
363
  ir2 = ir.styleSheet.cssRules[1]
366
364
  self.assertEqual(ir2.href, 'level2/css.css')
@@ -372,7 +370,7 @@ class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
372
370
  self.assertEqual(ir2.styleSheet.parentStyleSheet, None) # ir.styleSheet
373
371
  self.assertEqual(ir2.styleSheet.title, 'title2')
374
372
  self.assertEqual(ir2.styleSheet.cssText,
375
- '@charset "ascii";\na {\n color: red\n }'.encode())
373
+ b'@charset "ascii";\na {\n color: red\n }')
376
374
 
377
375
  sheet = css_parser.parseString('@import "CANNOT-FIND.css";')
378
376
  ir = sheet.cssRules[0]
@@ -381,9 +379,9 @@ class CSSImportRuleTestCase(test_cssrule.CSSRuleTestCase):
381
379
 
382
380
  def fetcher(url):
383
381
  if url.endswith('level1.css'):
384
- return None, '@charset "ascii"; @import "level2.css";'.encode()
382
+ return None, b'@charset "ascii"; @import "level2.css";'
385
383
  else:
386
- return None, 'a { color: red }'.encode()
384
+ return None, b'a { color: red }'
387
385
 
388
386
  parser = css_parser.CSSParser(fetcher=fetcher)
389
387
 
@@ -1,16 +1,16 @@
1
1
  """Testcases for css_parser.css.CSSMediaRule"""
2
2
 
3
- from __future__ import absolute_import
4
- from __future__ import unicode_literals
5
3
  import xml.dom
6
- from . import test_cssrule
4
+
7
5
  import css_parser
8
6
 
7
+ from . import test_cssrule
8
+
9
9
 
10
10
  class CSSMediaRuleTestCase(test_cssrule.CSSRuleTestCase):
11
11
 
12
12
  def setUp(self):
13
- super(CSSMediaRuleTestCase, self).setUp()
13
+ super().setUp()
14
14
  self.r = css_parser.css.CSSMediaRule()
15
15
  self.rRO = css_parser.css.CSSMediaRule(readonly=True)
16
16
  self.r_type = css_parser.css.CSSMediaRule.MEDIA_RULE
@@ -21,7 +21,7 @@ class CSSMediaRuleTestCase(test_cssrule.CSSRuleTestCase):
21
21
 
22
22
  def test_init(self):
23
23
  "CSSMediaRule.__init__()"
24
- super(CSSMediaRuleTestCase, self).test_init()
24
+ super().test_init()
25
25
 
26
26
  r = css_parser.css.CSSMediaRule()
27
27
  self.assertEqual(css_parser.css.CSSRuleList, type(r.cssRules))
@@ -132,7 +132,7 @@ class CSSMediaRuleTestCase(test_cssrule.CSSRuleTestCase):
132
132
  for b, a in mls.items():
133
133
  if a is None:
134
134
  a = b
135
- tests['@media%s%s' % (b, style)] = '@media%s%s' % (a, style)
135
+ tests[f'@media{b}{style}'] = f'@media{a}{style}'
136
136
 
137
137
  self.do_equal_p(tests)
138
138
  self.do_equal_r(tests)
@@ -340,7 +340,7 @@ class CSSMediaRuleTestCase(test_cssrule.CSSRuleTestCase):
340
340
  b { color: blue; }
341
341
  c { color: green; }
342
342
  }'''
343
- s1, s2, s3 = m.cssRules
343
+ _s1, s2, _s3 = m.cssRules
344
344
 
345
345
  r = css_parser.css.CSSStyleRule()
346
346
  self.assertRaises(xml.dom.IndexSizeErr, m.deleteRule, r)
@@ -10,7 +10,7 @@ from . import test_cssrule
10
10
  class CSSNamespaceRuleTestCase(test_cssrule.CSSRuleTestCase):
11
11
 
12
12
  def setUp(self):
13
- super(CSSNamespaceRuleTestCase, self).setUp()
13
+ super().setUp()
14
14
  self.r = css_parser.css.CSSNamespaceRule(namespaceURI='x')
15
15
  # self.rRO = css_parser.css.CSSNamespaceRule(namespaceURI='x',
16
16
  # readonly=True)
@@ -181,7 +181,7 @@ class CSSNamespaceRuleTestCase(test_cssrule.CSSRuleTestCase):
181
181
  for prefix in valid:
182
182
  r.prefix = prefix
183
183
  self.assertEqual(r.prefix, prefix)
184
- self.assertEqual('@namespace %s "u";' % prefix, r.cssText)
184
+ self.assertEqual(f'@namespace {prefix} "u";', r.cssText)
185
185
 
186
186
  invalid = ('1', ' x', ' ', ',')
187
187
  for prefix in invalid: