Test generating code with unicode characters. Primary purpose is to ensure compatibility with Python2.
(pytester, monkeypatch)
| 156 | |
| 157 | |
| 158 | def test_unicode_characters(pytester, monkeypatch): |
| 159 | """Test generating code with unicode characters. |
| 160 | |
| 161 | Primary purpose is to ensure compatibility with Python2. |
| 162 | """ |
| 163 | |
| 164 | pytester.makefile( |
| 165 | ".feature", |
| 166 | unicode_characters=textwrap.dedent( |
| 167 | """\ |
| 168 | Feature: Generating unicode characters |
| 169 | |
| 170 | Scenario: Calculating the circumference of a circle |
| 171 | Given We have a circle |
| 172 | When We want to know its circumference |
| 173 | Then We calculate 2 * ℼ * 𝑟 |
| 174 | """ |
| 175 | ), |
| 176 | ) |
| 177 | |
| 178 | result = pytester.run("pytest-bdd", "generate", "unicode_characters.feature") |
| 179 | expected_output = textwrap.dedent( |
| 180 | '''\ |
| 181 | """Generating unicode characters feature tests.""" |
| 182 | |
| 183 | from pytest_bdd import ( |
| 184 | given, |
| 185 | scenario, |
| 186 | then, |
| 187 | when, |
| 188 | ) |
| 189 | |
| 190 | |
| 191 | @scenario('unicode_characters.feature', 'Calculating the circumference of a circle') |
| 192 | def test_calculating_the_circumference_of_a_circle(): |
| 193 | """Calculating the circumference of a circle.""" |
| 194 | |
| 195 | |
| 196 | @given('We have a circle') |
| 197 | def _(): |
| 198 | """We have a circle.""" |
| 199 | raise NotImplementedError |
| 200 | |
| 201 | |
| 202 | @when('We want to know its circumference') |
| 203 | def _(): |
| 204 | """We want to know its circumference.""" |
| 205 | raise NotImplementedError |
| 206 | |
| 207 | |
| 208 | @then('We calculate 2 * ℼ * 𝑟') |
| 209 | def _(): |
| 210 | """We calculate 2 * ℼ * 𝑟.""" |
| 211 | raise NotImplementedError |
| 212 | ''' |
| 213 | ) |
| 214 | assert str(result.stdout) == expected_output |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…