|
1 | 1 | from __future__ import (absolute_import, division, print_function,
|
2 | 2 | unicode_literals)
|
3 | 3 |
|
4 |
| -from nose.tools import assert_raises, assert_equal |
| 4 | +from nose.tools import (assert_raises, assert_equal, assert_regexp_matches, |
| 5 | + assert_not_regexp_matches) |
5 | 6 | from nose.plugins.skip import SkipTest
|
6 | 7 |
|
7 | 8 | from .. import unpack_labeled_data
|
@@ -327,3 +328,49 @@ def funcy(ax, *args, **kwargs):
|
327 | 328 | "x: [1, 2], y: [8, 9], ls: x, w: xyz, label: ")
|
328 | 329 | assert_equal(func2(None, "a", "b", w="x", label="text", data=data),
|
329 | 330 | "x: [1, 2], y: [8, 9], ls: x, w: xyz, label: text")
|
| 331 | + |
| 332 | + |
| 333 | +def test_docstring_addition(): |
| 334 | + @unpack_labeled_data() |
| 335 | + def funcy(ax, *args, **kwargs): |
| 336 | + """Funcy does nothing""" |
| 337 | + pass |
| 338 | + |
| 339 | + assert_regexp_matches(funcy.__doc__, |
| 340 | + r".*All positional and all keyword arguments\.") |
| 341 | + assert_not_regexp_matches(funcy.__doc__, r".*All positional arguments\.") |
| 342 | + assert_not_regexp_matches(funcy.__doc__, |
| 343 | + r".*All arguments with the following names: .*") |
| 344 | + |
| 345 | + @unpack_labeled_data(replace_all_args=True, replace_names=[]) |
| 346 | + def funcy(ax, x, y, z, bar=None): |
| 347 | + """Funcy does nothing""" |
| 348 | + pass |
| 349 | + |
| 350 | + assert_regexp_matches(funcy.__doc__, r".*All positional arguments\.") |
| 351 | + assert_not_regexp_matches(funcy.__doc__, |
| 352 | + r".*All positional and all keyword arguments\.") |
| 353 | + assert_not_regexp_matches(funcy.__doc__, |
| 354 | + r".*All arguments with the following names: .*") |
| 355 | + |
| 356 | + @unpack_labeled_data(replace_all_args=True, replace_names=["bar"]) |
| 357 | + def funcy(ax, x, y, z, bar=None): |
| 358 | + """Funcy does nothing""" |
| 359 | + pass |
| 360 | + |
| 361 | + assert_regexp_matches(funcy.__doc__, r".*All positional arguments\.") |
| 362 | + assert_regexp_matches(funcy.__doc__, |
| 363 | + r".*All arguments with the following names: 'bar'\.") |
| 364 | + assert_not_regexp_matches(funcy.__doc__, |
| 365 | + r".*All positional and all keyword arguments\.") |
| 366 | + |
| 367 | + @unpack_labeled_data(replace_names=["x", "bar"]) |
| 368 | + def funcy(ax, x, y, z, bar=None): |
| 369 | + """Funcy does nothing""" |
| 370 | + pass |
| 371 | + |
| 372 | + assert_regexp_matches(funcy.__doc__, |
| 373 | + r".*All arguments with the following names: 'x', 'bar'\.") |
| 374 | + assert_not_regexp_matches(funcy.__doc__, |
| 375 | + r".*All positional and all keyword arguments\.") |
| 376 | + assert_not_regexp_matches(funcy.__doc__, r".*All positional arguments\.") |
0 commit comments