|
36 | 36 | normalize_summary() |
37 | 37 | remove_section_headers() |
38 | 38 | split_first_sentence() |
| 39 | + split_summary() |
39 | 40 | split_summary_and_description() |
40 | 41 | strip_leading_blank_lines() |
41 | 42 | strip_quotes() |
@@ -261,6 +262,40 @@ def test_split_first_sentence(self): |
261 | 262 | "\none\ntwo", |
262 | 263 | ) == docformatter.split_first_sentence("This is the first:\none\ntwo") |
263 | 264 |
|
| 265 | + @pytest.mark.unit |
| 266 | + def test_split_one_sentence_summary(self): |
| 267 | + """A single sentence summary should be returned as is. |
| 268 | +
|
| 269 | + See issue #283. |
| 270 | + """ |
| 271 | + assert [ |
| 272 | + "This is a sentence.", |
| 273 | + "", |
| 274 | + ] == docformatter.split_summary(["This is a sentence.", ""]) |
| 275 | + |
| 276 | + assert [ |
| 277 | + "This e.g. a sentence.", |
| 278 | + "", |
| 279 | + ] == docformatter.split_summary(["This e.g. a sentence.", ""]) |
| 280 | + |
| 281 | + @pytest.mark.unit |
| 282 | + def test_split_multi_sentence_summary(self): |
| 283 | + """A multi-sentence summary should return only the first as the summary. |
| 284 | +
|
| 285 | + See issue #283. |
| 286 | + """ |
| 287 | + assert [ |
| 288 | + "This is a sentence.", |
| 289 | + "", |
| 290 | + "This is another.", |
| 291 | + ] == docformatter.split_summary(["This is a sentence. This is another.", ""]) |
| 292 | + |
| 293 | + assert [ |
| 294 | + "This e.g. a sentence.", |
| 295 | + "", |
| 296 | + "This is another.", |
| 297 | + ] == docformatter.split_summary(["This e.g. a sentence. This is another.", ""]) |
| 298 | + |
264 | 299 | @pytest.mark.unit |
265 | 300 | def test_split_summary_and_description(self): |
266 | 301 | """""" |
@@ -317,9 +352,7 @@ def test_split_summary_and_description_with_capital(self): |
317 | 352 | assert ( |
318 | 353 | "This is the first\nWashington", |
319 | 354 | "", |
320 | | - ) == docformatter.split_summary_and_description( |
321 | | - "This is the first\nWashington" |
322 | | - ) |
| 355 | + ) == docformatter.split_summary_and_description("This is the first\nWashington") |
323 | 356 |
|
324 | 357 | @pytest.mark.unit |
325 | 358 | def test_split_summary_and_description_with_list_on_other_line(self): |
@@ -351,53 +384,41 @@ def test_split_summary_and_description_with_colon(self): |
351 | 384 | assert ( |
352 | 385 | "This is the first:", |
353 | 386 | "one\ntwo", |
354 | | - ) == docformatter.split_summary_and_description( |
355 | | - "This is the first:\none\ntwo" |
356 | | - ) |
| 387 | + ) == docformatter.split_summary_and_description("This is the first:\none\ntwo") |
357 | 388 |
|
358 | 389 | @pytest.mark.unit |
359 | 390 | def test_split_summary_and_description_with_exclamation(self): |
360 | 391 | """""" |
361 | 392 | assert ( |
362 | 393 | "This is the first!", |
363 | 394 | "one\ntwo", |
364 | | - ) == docformatter.split_summary_and_description( |
365 | | - "This is the first!\none\ntwo" |
366 | | - ) |
| 395 | + ) == docformatter.split_summary_and_description("This is the first!\none\ntwo") |
367 | 396 |
|
368 | 397 | @pytest.mark.unit |
369 | 398 | def test_split_summary_and_description_with_question_mark(self): |
370 | 399 | """""" |
371 | 400 | assert ( |
372 | 401 | "This is the first?", |
373 | 402 | "one\ntwo", |
374 | | - ) == docformatter.split_summary_and_description( |
375 | | - "This is the first?\none\ntwo" |
376 | | - ) |
| 403 | + ) == docformatter.split_summary_and_description("This is the first?\none\ntwo") |
377 | 404 |
|
378 | 405 | @pytest.mark.unit |
379 | 406 | def test_split_summary_and_description_with_quote(self): |
380 | 407 | """""" |
381 | 408 | assert ( |
382 | 409 | 'This is the first\n"one".', |
383 | 410 | "", |
384 | | - ) == docformatter.split_summary_and_description( |
385 | | - 'This is the first\n"one".' |
386 | | - ) |
| 411 | + ) == docformatter.split_summary_and_description('This is the first\n"one".') |
387 | 412 |
|
388 | 413 | assert ( |
389 | 414 | "This is the first\n'one'.", |
390 | 415 | "", |
391 | | - ) == docformatter.split_summary_and_description( |
392 | | - "This is the first\n'one'." |
393 | | - ) |
| 416 | + ) == docformatter.split_summary_and_description("This is the first\n'one'.") |
394 | 417 |
|
395 | 418 | assert ( |
396 | 419 | "This is the first\n``one``.", |
397 | 420 | "", |
398 | | - ) == docformatter.split_summary_and_description( |
399 | | - "This is the first\n``one``." |
400 | | - ) |
| 421 | + ) == docformatter.split_summary_and_description("This is the first\n``one``.") |
401 | 422 |
|
402 | 423 | @pytest.mark.unit |
403 | 424 | def test_split_summary_and_description_with_punctuation(self): |
@@ -461,9 +482,7 @@ def test_split_summary_and_description_with_abbreviation(self): |
461 | 482 | "Test Mrs. now", |
462 | 483 | "Test Ms. now", |
463 | 484 | ]: |
464 | | - assert (text, "") == docformatter.split_summary_and_description( |
465 | | - text |
466 | | - ) |
| 485 | + assert (text, "") == docformatter.split_summary_and_description(text) |
467 | 486 |
|
468 | 487 | @pytest.mark.unit |
469 | 488 | def test_split_summary_and_description_with_url(self): |
@@ -497,9 +516,7 @@ class TestStrippers: |
497 | 516 | @pytest.mark.unit |
498 | 517 | def test_remove_section_header(self): |
499 | 518 | """Remove section header directives.""" |
500 | | - assert "foo\nbar\n" == docformatter.remove_section_header( |
501 | | - "----\nfoo\nbar\n" |
502 | | - ) |
| 519 | + assert "foo\nbar\n" == docformatter.remove_section_header("----\nfoo\nbar\n") |
503 | 520 |
|
504 | 521 | line = "foo\nbar\n" |
505 | 522 | assert line == docformatter.remove_section_header(line) |
|
0 commit comments