-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
unittest.po
3072 lines (2584 loc) · 107 KB
/
unittest.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
# Liang-Bo Wang <me@liang2.tw>, 2016
# Liang-Bo Wang <me@liang2.tw>, 2016
# Jason <chairco@gmail.com>, 2016
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-09 00:03+0000\n"
"PO-Revision-Date: 2022-10-16 06:03+0800\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.1.1\n"
#: ../../library/unittest.rst:2
msgid ":mod:`!unittest` --- Unit testing framework"
msgstr ":mod:`!unittest` --- 單元測試框架"
#: ../../library/unittest.rst:12
msgid "**Source code:** :source:`Lib/unittest/__init__.py`"
msgstr "**原始碼:**\\ :source:`Lib/unittest/__init__.py`"
#: ../../library/unittest.rst:16
msgid ""
"(If you are already familiar with the basic concepts of testing, you might "
"want to skip to :ref:`the list of assert methods <assert-methods>`.)"
msgstr ""
"(假如你已經熟悉相關基礎的測試概念,你可能會希望跳過以下段落,直接參考 :ref:"
"`assert 方法清單 <assert-methods>`\\ 。)"
#: ../../library/unittest.rst:19
msgid ""
"The :mod:`unittest` unit testing framework was originally inspired by JUnit "
"and has a similar flavor as major unit testing frameworks in other "
"languages. It supports test automation, sharing of setup and shutdown code "
"for tests, aggregation of tests into collections, and independence of the "
"tests from the reporting framework."
msgstr ""
":mod:`unittest` 原生的單元測試框架最初由 JUnit 開發,和其他程式語言相似有主要"
"的單元測試框架。支援自動化測試,對測試分享安裝與關閉程式碼,集合所有匯總的測"
"試,並且獨立各個測試報告框架。"
#: ../../library/unittest.rst:25
msgid ""
"To achieve this, :mod:`unittest` supports some important concepts in an "
"object-oriented way:"
msgstr ":mod:`unittest` 用來作為實現支援一些重要的物件導向方法的概念:"
#: ../../library/unittest.rst:28
msgid "test fixture"
msgstr "test fixture"
#: ../../library/unittest.rst:29
msgid ""
"A :dfn:`test fixture` represents the preparation needed to perform one or "
"more tests, and any associated cleanup actions. This may involve, for "
"example, creating temporary or proxy databases, directories, or starting a "
"server process."
msgstr ""
"一個 :dfn:`test fixture` 代表執行一個或多個測試所需要的準備,以及其他相關清理"
"操作,例如可以是建立臨時性的或是代理用 (proxy) 資料庫、目錄、或是啟動一個伺服"
"器程序。"
#: ../../library/unittest.rst:34
msgid "test case"
msgstr "test case(測試用例)"
#: ../../library/unittest.rst:35
msgid ""
"A :dfn:`test case` is the individual unit of testing. It checks for a "
"specific response to a particular set of inputs. :mod:`unittest` provides a "
"base class, :class:`TestCase`, which may be used to create new test cases."
msgstr ""
"一個 :dfn:`test case` 是一個獨立的單元測試。這是用來確認一個特定設定的輸入的"
"特殊回饋。 :mod:`unittest` 提供一個基礎類別,類別 :class:`TestCase`\\ ,可以"
"用來建立一個新的測試條例。"
#: ../../library/unittest.rst:39
msgid "test suite"
msgstr "test suite(測試套件)"
#: ../../library/unittest.rst:40
msgid ""
"A :dfn:`test suite` is a collection of test cases, test suites, or both. It "
"is used to aggregate tests that should be executed together."
msgstr ""
":dfn:`test suite` 是一個搜集測試條例,測試套件,或是兩者皆有。它需要一起被執"
"行並用來匯總測試。"
#: ../../library/unittest.rst:43
msgid "test runner"
msgstr "test runner(測試執行器)"
#: ../../library/unittest.rst:44
msgid ""
"A :dfn:`test runner` is a component which orchestrates the execution of "
"tests and provides the outcome to the user. The runner may use a graphical "
"interface, a textual interface, or return a special value to indicate the "
"results of executing the tests."
msgstr ""
":dfn:`test runner` 是一個編排測試執行與提供結果給使用者的一個元件。執行器可以"
"使用圖形化介面,文字介面或是回傳一個特別值用來標示出執行測試的結果。"
#: ../../library/unittest.rst:52
msgid "Module :mod:`doctest`"
msgstr ":mod:`doctest` 模組"
#: ../../library/unittest.rst:53
msgid "Another test-support module with a very different flavor."
msgstr "另一個執行測試的模組,但使用不一樣的測試方法與規範。"
#: ../../library/unittest.rst:55
msgid ""
"`Simple Smalltalk Testing: With Patterns <https://web.archive.org/"
"web/20150315073817/http://www.xprogramming.com/testfram.htm>`_"
msgstr ""
"`Simple Smalltalk Testing: With Patterns <https://web.archive.org/"
"web/20150315073817/http://www.xprogramming.com/testfram.htm>`_"
#: ../../library/unittest.rst:56
msgid ""
"Kent Beck's original paper on testing frameworks using the pattern shared "
"by :mod:`unittest`."
msgstr "Kent Beck 的原始論文討論使用 :mod:`unittest` 這樣模式的測試框架。"
#: ../../library/unittest.rst:59
msgid "`pytest <https://docs.pytest.org/>`_"
msgstr "`pytest <https://docs.pytest.org/>`_"
#: ../../library/unittest.rst:60
msgid ""
"Third-party unittest framework with a lighter-weight syntax for writing "
"tests. For example, ``assert func(10) == 42``."
msgstr ""
"第三方的單元測試框架,但在撰寫測試時使用更輕量的語法。例如: ``assert "
"func(10) == 42``\\ 。"
#: ../../library/unittest.rst:63
msgid ""
"`The Python Testing Tools Taxonomy <https://wiki.python.org/moin/"
"PythonTestingToolsTaxonomy>`_"
msgstr ""
"`The Python Testing Tools Taxonomy <https://wiki.python.org/moin/"
"PythonTestingToolsTaxonomy>`_"
#: ../../library/unittest.rst:64
msgid ""
"An extensive list of Python testing tools including functional testing "
"frameworks and mock object libraries."
msgstr ""
"一份詳細的 Python 測試工具列表,包含 functional testing 框架和mock object 函"
"式庫。"
#: ../../library/unittest.rst:67
msgid ""
"`Testing in Python Mailing List <http://lists.idyll.org/listinfo/testing-in-"
"python>`_"
msgstr ""
"`Testing in Python Mailing List <http://lists.idyll.org/listinfo/testing-in-"
"python>`_"
#: ../../library/unittest.rst:68
msgid ""
"A special-interest-group for discussion of testing, and testing tools, in "
"Python."
msgstr "一個專門興趣的群組用來討論 Python 中的測試方式與測試工具。"
#: ../../library/unittest.rst:71
msgid ""
"The script :file:`Tools/unittestgui/unittestgui.py` in the Python source "
"distribution is a GUI tool for test discovery and execution. This is "
"intended largely for ease of use for those new to unit testing. For "
"production environments it is recommended that tests be driven by a "
"continuous integration system such as `Buildbot <https://buildbot.net/>`_, "
"`Jenkins <https://www.jenkins.io/>`_, `GitHub Actions <https://github.com/"
"features/actions>`_, or `AppVeyor <https://www.appveyor.com/>`_."
msgstr ""
#: ../../library/unittest.rst:83
msgid "Basic example"
msgstr "簡單範例"
#: ../../library/unittest.rst:85
msgid ""
"The :mod:`unittest` module provides a rich set of tools for constructing and "
"running tests. This section demonstrates that a small subset of the tools "
"suffice to meet the needs of most users."
msgstr ""
":mod:`unittest` 模組提供一系列豐富的工具用來建構與執行測試。本節將展示這一系"
"列工具中一部份,它們已能滿足大部份使用者需求。"
#: ../../library/unittest.rst:89
msgid "Here is a short script to test three string methods::"
msgstr ""
"這是一段簡短的腳本用來測試 3 個字串方法:\n"
"\n"
"::"
#: ../../library/unittest.rst:113
msgid ""
"A testcase is created by subclassing :class:`unittest.TestCase`. The three "
"individual tests are defined with methods whose names start with the letters "
"``test``. This naming convention informs the test runner about which "
"methods represent tests."
msgstr ""
"測試用例 (testcase) 可以透過繼承 :class:`unittest.TestCase` 類別來建立。這裡"
"定義了三個獨立的物件方法,名稱皆以 ``test`` 開頭。這樣的命名方式能告知 test "
"runner 哪些物件方法為定義的測試。"
#: ../../library/unittest.rst:118
msgid ""
"The crux of each test is a call to :meth:`~TestCase.assertEqual` to check "
"for an expected result; :meth:`~TestCase.assertTrue` or :meth:`~TestCase."
"assertFalse` to verify a condition; or :meth:`~TestCase.assertRaises` to "
"verify that a specific exception gets raised. These methods are used "
"instead of the :keyword:`assert` statement so the test runner can accumulate "
"all test results and produce a report."
msgstr ""
"每個測試的關鍵為呼叫 :meth:`~TestCase.assertEqual` 來確認是否為期望的結果; :"
"meth:`~TestCase.assertTrue` 或是 :meth:`~TestCase.assertFalse` 用來驗證一個條"
"件式; :meth:`~TestCase.assertRaises` 用來驗證是否觸發一個特定的 exception。"
"使用這些物件方法來取代 :keyword:`assert` 陳述句,將能使 test runner 收集所有"
"的測試結果並產生一個報表。"
#: ../../library/unittest.rst:125
msgid ""
"The :meth:`~TestCase.setUp` and :meth:`~TestCase.tearDown` methods allow you "
"to define instructions that will be executed before and after each test "
"method. They are covered in more detail in the section :ref:`organizing-"
"tests`."
msgstr ""
#: ../../library/unittest.rst:129
msgid ""
"The final block shows a simple way to run the tests. :func:`unittest.main` "
"provides a command-line interface to the test script. When run from the "
"command line, the above script produces an output that looks like this::"
msgstr ""
"最後將顯示一個簡單的方法去執行測試 :func:`unittest.main` 提供一個命令執行列介"
"面測試腳本。當透過命令執行列執行,輸出結果將會像是:\n"
"\n"
"::"
#: ../../library/unittest.rst:139
msgid ""
"Passing the ``-v`` option to your test script will instruct :func:`unittest."
"main` to enable a higher level of verbosity, and produce the following "
"output::"
msgstr ""
"在測試時加入 ``-v`` 選項將指示 :func:`unittest.main` 提高 verbosity 層級,產"
"生以下的輸出:\n"
"\n"
"::"
#: ../../library/unittest.rst:151
msgid ""
"The above examples show the most commonly used :mod:`unittest` features "
"which are sufficient to meet many everyday testing needs. The remainder of "
"the documentation explores the full feature set from first principles."
msgstr ""
"以上的例子顯示大多數使用 :mod:`unittest` 特徵足以滿足大多數日常測試的需求。接"
"下來第一部分文件的剩餘部分將繼續探索完整特徵設定。"
#: ../../library/unittest.rst:155
msgid ""
"The behavior of returning a value from a test method (other than the default "
"``None`` value), is now deprecated."
msgstr ""
#: ../../library/unittest.rst:163
msgid "Command-Line Interface"
msgstr "命令執行列介面 (Command-Line Interface)"
#: ../../library/unittest.rst:165
msgid ""
"The unittest module can be used from the command line to run tests from "
"modules, classes or even individual test methods::"
msgstr ""
"單元測試模組可以透過命令執行列執行測試模組,物件甚至個別的測試方法:\n"
"\n"
"::"
#: ../../library/unittest.rst:172
msgid ""
"You can pass in a list with any combination of module names, and fully "
"qualified class or method names."
msgstr "你可以通過一個串列與任何模組名稱的組合,完全符合類別與方法的名稱。"
#: ../../library/unittest.rst:175
msgid "Test modules can be specified by file path as well::"
msgstr ""
"測試模組可以根據檔案路徑指定:\n"
"\n"
"::"
#: ../../library/unittest.rst:179
msgid ""
"This allows you to use the shell filename completion to specify the test "
"module. The file specified must still be importable as a module. The path is "
"converted to a module name by removing the '.py' and converting path "
"separators into '.'. If you want to execute a test file that isn't "
"importable as a module you should execute the file directly instead."
msgstr ""
"這允許你使用 shell 檔案名稱補完功能 (filename completion) 來指定測試模組。給"
"定的檔案路徑必須亦能被當作模組 import。此路徑轉換為模組名稱的方式為移除 '."
"py' 並將路徑分隔符 (path separator) 轉換成 '.'。 假如你的測試檔案無法被 "
"import 成模組,你應該直接執行該測試檔案。"
#: ../../library/unittest.rst:185
msgid ""
"You can run tests with more detail (higher verbosity) by passing in the -v "
"flag::"
msgstr ""
"通過增加 -v 的旗標數,可以在你執行測試時得到更多細節(更高的 verbosity):\n"
"\n"
"::"
#: ../../library/unittest.rst:189
msgid ""
"When executed without arguments :ref:`unittest-test-discovery` is started::"
msgstr ""
"若執行時不代任何引數,將執行 :ref:`unittest-test-discovery`\\ :\n"
"\n"
"::"
#: ../../library/unittest.rst:193
msgid "For a list of all the command-line options::"
msgstr ""
"列出所有命令列選項:\n"
"\n"
"::"
#: ../../library/unittest.rst:197
msgid ""
"In earlier versions it was only possible to run individual test methods and "
"not modules or classes."
msgstr "在早期的版本可以個別執行測試方法和不需要模組或是類別。"
#: ../../library/unittest.rst:203
msgid "Command-line options"
msgstr "命令列模式選項"
#: ../../library/unittest.rst:205
msgid ":program:`unittest` supports these command-line options:"
msgstr ":program:`unittest` 支援以下命令列選項:"
#: ../../library/unittest.rst:211
msgid ""
"The standard output and standard error streams are buffered during the test "
"run. Output during a passing test is discarded. Output is echoed normally on "
"test fail or error and is added to the failure messages."
msgstr ""
"Standard output 與 standard error stream 將在測試執行被緩衝 (buffer)。這些輸"
"出在測試通過時被丟棄。若是測試錯誤或失則,這些輸出將會正常地被印出,並且被加"
"入至錯誤訊息中。"
#: ../../library/unittest.rst:217
msgid ""
":kbd:`Control-C` during the test run waits for the current test to end and "
"then reports all the results so far. A second :kbd:`Control-C` raises the "
"normal :exc:`KeyboardInterrupt` exception."
msgstr ""
":kbd:`Control-C` 測試執行過程中等待正確的測試結果並回報目前為止所有的測試結"
"果。第二個 :kbd:`Control-C` 拋出一般例外 :exc:`KeyboardInterrupt`\\ 。"
#: ../../library/unittest.rst:221
msgid ""
"See `Signal Handling`_ for the functions that provide this functionality."
msgstr "參照 `Signal Handling`_ 針對函式提供的功能。"
#: ../../library/unittest.rst:225
msgid "Stop the test run on the first error or failure."
msgstr "在第一次錯誤或是失敗停止執行測試。"
#: ../../library/unittest.rst:229
msgid ""
"Only run test methods and classes that match the pattern or substring. This "
"option may be used multiple times, in which case all test cases that match "
"any of the given patterns are included."
msgstr ""
#: ../../library/unittest.rst:233
msgid ""
"Patterns that contain a wildcard character (``*``) are matched against the "
"test name using :meth:`fnmatch.fnmatchcase`; otherwise simple case-sensitive "
"substring matching is used."
msgstr ""
#: ../../library/unittest.rst:237
msgid ""
"Patterns are matched against the fully qualified test method name as "
"imported by the test loader."
msgstr ""
#: ../../library/unittest.rst:240
msgid ""
"For example, ``-k foo`` matches ``foo_tests.SomeTest.test_something``, "
"``bar_tests.SomeTest.test_foo``, but not ``bar_tests.FooTest."
"test_something``."
msgstr ""
#: ../../library/unittest.rst:245
msgid "Show local variables in tracebacks."
msgstr "透過 traceback 顯示本地變數。"
#: ../../library/unittest.rst:249
msgid "Show the N slowest test cases (N=0 for all)."
msgstr ""
#: ../../library/unittest.rst:251
msgid "The command-line options ``-b``, ``-c`` and ``-f`` were added."
msgstr "增加命令列模式選項 ``-b`` 、 ``-c`` 與 ``-f``\\ 。"
#: ../../library/unittest.rst:254
msgid "The command-line option ``--locals``."
msgstr "命令列選項 ``--locals``。"
#: ../../library/unittest.rst:257
msgid "The command-line option ``-k``."
msgstr "命令列選項 ``-k``。"
#: ../../library/unittest.rst:260
msgid "The command-line option ``--durations``."
msgstr "命令列選項 ``--durations``。"
#: ../../library/unittest.rst:263
msgid ""
"The command line can also be used for test discovery, for running all of the "
"tests in a project or just a subset."
msgstr ""
"對執行所有的專案或是一個子集合測試,命令列模式可以可以被用來做測試探索。"
#: ../../library/unittest.rst:269
msgid "Test Discovery"
msgstr "Test Discovery(測試探索)"
#: ../../library/unittest.rst:273
msgid ""
"Unittest supports simple test discovery. In order to be compatible with test "
"discovery, all of the test files must be :ref:`modules <tut-modules>` or :"
"ref:`packages <tut-packages>` importable from the top-level directory of the "
"project (this means that their filenames must be valid :ref:`identifiers "
"<identifiers>`)."
msgstr ""
"單元測試支援簡單的 test discovery(測試探索)。為了相容於測試探索,所有的測試"
"檔案都要是\\ :ref:`模組 <tut-modules>`\\ 或是\\ :ref:`套件 <tut-packages>`,"
"並能從專案的最上層目錄中 import(代表它們的檔案名稱必須是有效的 :ref:"
"`identifiers <identifiers>`\\ )。"
#: ../../library/unittest.rst:279
msgid ""
"Test discovery is implemented in :meth:`TestLoader.discover`, but can also "
"be used from the command line. The basic command-line usage is::"
msgstr ""
"Test discovery(測試探索)實作在 :meth:`TestLoader.discover`\\ ,但也可以被用"
"於命令列模式。基本的命令列模式用法如下:\n"
"\n"
"::"
#: ../../library/unittest.rst:287
msgid ""
"As a shortcut, ``python -m unittest`` is the equivalent of ``python -m "
"unittest discover``. If you want to pass arguments to test discovery the "
"``discover`` sub-command must be used explicitly."
msgstr ""
"``python -m unittest`` 作為捷徑,其功能相當於 ``python -m unittest "
"discover``\\ 。假如你想傳遞引數至探索測試的話,一定要明確地加入 ``discover`` "
"子指令。"
#: ../../library/unittest.rst:291
msgid "The ``discover`` sub-command has the following options:"
msgstr "``discover`` 子指令有以下幾個選項:"
#: ../../library/unittest.rst:297
msgid "Verbose output"
msgstr "詳細(verbose)輸出"
#: ../../library/unittest.rst:301
msgid "Directory to start discovery (``.`` default)"
msgstr "開始尋找的資料夾(預設為 ``.``\\ )"
#: ../../library/unittest.rst:305
msgid "Pattern to match test files (``test*.py`` default)"
msgstr "匹配測試檔案的模式(預設為 ``test*.py``\\ )"
#: ../../library/unittest.rst:309
msgid "Top level directory of project (defaults to start directory)"
msgstr "專案的最高階層目錄 (defaults to start directory)"
#: ../../library/unittest.rst:311
msgid ""
"The :option:`-s`, :option:`-p`, and :option:`-t` options can be passed in as "
"positional arguments in that order. The following two command lines are "
"equivalent::"
msgstr ""
":option:`-s`, :option:`-p`, 和 :option:`-t` 選項依照傳遞位置作為引數排序順"
"序。以下兩個命令列被視為等價:\n"
"\n"
"::"
#: ../../library/unittest.rst:318
msgid ""
"As well as being a path it is possible to pass a package name, for example "
"``myproject.subpackage.test``, as the start directory. The package name you "
"supply will then be imported and its location on the filesystem will be used "
"as the start directory."
msgstr ""
#: ../../library/unittest.rst:325
msgid ""
"Test discovery loads tests by importing them. Once test discovery has found "
"all the test files from the start directory you specify it turns the paths "
"into package names to import. For example :file:`foo/bar/baz.py` will be "
"imported as ``foo.bar.baz``."
msgstr ""
#: ../../library/unittest.rst:330
msgid ""
"If you have a package installed globally and attempt test discovery on a "
"different copy of the package then the import *could* happen from the wrong "
"place. If this happens test discovery will warn you and exit."
msgstr ""
#: ../../library/unittest.rst:334
msgid ""
"If you supply the start directory as a package name rather than a path to a "
"directory then discover assumes that whichever location it imports from is "
"the location you intended, so you will not get the warning."
msgstr ""
#: ../../library/unittest.rst:339
msgid ""
"Test modules and packages can customize test loading and discovery by "
"through the `load_tests protocol`_."
msgstr ""
#: ../../library/unittest.rst:342
msgid ""
"Test discovery supports :term:`namespace packages <namespace package>` for "
"the start directory. Note that you need to specify the top level directory "
"too (e.g. ``python -m unittest discover -s root/namespace -t root``)."
msgstr ""
#: ../../library/unittest.rst:348
msgid ""
":mod:`unittest` dropped the :term:`namespace packages <namespace package>` "
"support in Python 3.11. It has been broken since Python 3.7. Start directory "
"and subdirectories containing tests must be regular package that have "
"``__init__.py`` file."
msgstr ""
#: ../../library/unittest.rst:354
msgid ""
"Directories containing start directory still can be a namespace package. In "
"this case, you need to specify start directory as dotted package name, and "
"target directory explicitly. For example::"
msgstr ""
#: ../../library/unittest.rst:370
msgid "Organizing test code"
msgstr ""
#: ../../library/unittest.rst:372
msgid ""
"The basic building blocks of unit testing are :dfn:`test cases` --- single "
"scenarios that must be set up and checked for correctness. In :mod:"
"`unittest`, test cases are represented by :class:`unittest.TestCase` "
"instances. To make your own test cases you must write subclasses of :class:"
"`TestCase` or use :class:`FunctionTestCase`."
msgstr ""
#: ../../library/unittest.rst:378
msgid ""
"The testing code of a :class:`TestCase` instance should be entirely self "
"contained, such that it can be run either in isolation or in arbitrary "
"combination with any number of other test cases."
msgstr ""
#: ../../library/unittest.rst:382
msgid ""
"The simplest :class:`TestCase` subclass will simply implement a test method "
"(i.e. a method whose name starts with ``test``) in order to perform specific "
"testing code::"
msgstr ""
#: ../../library/unittest.rst:393
msgid ""
"Note that in order to test something, we use one of the :ref:`assert\\* "
"methods <assert-methods>` provided by the :class:`TestCase` base class. If "
"the test fails, an exception will be raised with an explanatory message, "
"and :mod:`unittest` will identify the test case as a :dfn:`failure`. Any "
"other exceptions will be treated as :dfn:`errors`."
msgstr ""
#: ../../library/unittest.rst:399
msgid ""
"Tests can be numerous, and their set-up can be repetitive. Luckily, we can "
"factor out set-up code by implementing a method called :meth:`~TestCase."
"setUp`, which the testing framework will automatically call for every single "
"test we run::"
msgstr ""
#: ../../library/unittest.rst:420
msgid ""
"The order in which the various tests will be run is determined by sorting "
"the test method names with respect to the built-in ordering for strings."
msgstr ""
#: ../../library/unittest.rst:424
msgid ""
"If the :meth:`~TestCase.setUp` method raises an exception while the test is "
"running, the framework will consider the test to have suffered an error, and "
"the test method will not be executed."
msgstr ""
#: ../../library/unittest.rst:428
msgid ""
"Similarly, we can provide a :meth:`~TestCase.tearDown` method that tidies up "
"after the test method has been run::"
msgstr ""
#: ../../library/unittest.rst:440
msgid ""
"If :meth:`~TestCase.setUp` succeeded, :meth:`~TestCase.tearDown` will be run "
"whether the test method succeeded or not."
msgstr ""
#: ../../library/unittest.rst:443
msgid ""
"Such a working environment for the testing code is called a :dfn:`test "
"fixture`. A new TestCase instance is created as a unique test fixture used "
"to execute each individual test method. Thus :meth:`~TestCase.setUp`, :meth:"
"`~TestCase.tearDown`, and :meth:`~TestCase.__init__` will be called once per "
"test."
msgstr ""
#: ../../library/unittest.rst:449
msgid ""
"It is recommended that you use TestCase implementations to group tests "
"together according to the features they test. :mod:`unittest` provides a "
"mechanism for this: the :dfn:`test suite`, represented by :mod:`unittest`'s :"
"class:`TestSuite` class. In most cases, calling :func:`unittest.main` will "
"do the right thing and collect all the module's test cases for you and "
"execute them."
msgstr ""
#: ../../library/unittest.rst:456
msgid ""
"However, should you want to customize the building of your test suite, you "
"can do it yourself::"
msgstr ""
#: ../../library/unittest.rst:469
msgid ""
"You can place the definitions of test cases and test suites in the same "
"modules as the code they are to test (such as :file:`widget.py`), but there "
"are several advantages to placing the test code in a separate module, such "
"as :file:`test_widget.py`:"
msgstr ""
#: ../../library/unittest.rst:474
msgid "The test module can be run standalone from the command line."
msgstr ""
#: ../../library/unittest.rst:476
msgid "The test code can more easily be separated from shipped code."
msgstr ""
#: ../../library/unittest.rst:478
msgid ""
"There is less temptation to change test code to fit the code it tests "
"without a good reason."
msgstr ""
#: ../../library/unittest.rst:481
msgid ""
"Test code should be modified much less frequently than the code it tests."
msgstr ""
#: ../../library/unittest.rst:483
msgid "Tested code can be refactored more easily."
msgstr ""
#: ../../library/unittest.rst:485
msgid ""
"Tests for modules written in C must be in separate modules anyway, so why "
"not be consistent?"
msgstr ""
#: ../../library/unittest.rst:488
msgid ""
"If the testing strategy changes, there is no need to change the source code."
msgstr ""
#: ../../library/unittest.rst:494
msgid "Re-using old test code"
msgstr ""
#: ../../library/unittest.rst:496
msgid ""
"Some users will find that they have existing test code that they would like "
"to run from :mod:`unittest`, without converting every old test function to "
"a :class:`TestCase` subclass."
msgstr ""
#: ../../library/unittest.rst:500
msgid ""
"For this reason, :mod:`unittest` provides a :class:`FunctionTestCase` class. "
"This subclass of :class:`TestCase` can be used to wrap an existing test "
"function. Set-up and tear-down functions can also be provided."
msgstr ""
#: ../../library/unittest.rst:504
msgid "Given the following test function::"
msgstr ""
#: ../../library/unittest.rst:511
msgid ""
"one can create an equivalent test case instance as follows, with optional "
"set-up and tear-down methods::"
msgstr ""
#: ../../library/unittest.rst:520
msgid ""
"Even though :class:`FunctionTestCase` can be used to quickly convert an "
"existing test base over to a :mod:`unittest`\\ -based system, this approach "
"is not recommended. Taking the time to set up proper :class:`TestCase` "
"subclasses will make future test refactorings infinitely easier."
msgstr ""
#: ../../library/unittest.rst:525
msgid ""
"In some cases, the existing tests may have been written using the :mod:"
"`doctest` module. If so, :mod:`doctest` provides a :class:`DocTestSuite` "
"class that can automatically build :class:`unittest.TestSuite` instances "
"from the existing :mod:`doctest`\\ -based tests."
msgstr ""
#: ../../library/unittest.rst:534
msgid "Skipping tests and expected failures"
msgstr ""
#: ../../library/unittest.rst:538
msgid ""
"Unittest supports skipping individual test methods and even whole classes of "
"tests. In addition, it supports marking a test as an \"expected failure,\" "
"a test that is broken and will fail, but shouldn't be counted as a failure "
"on a :class:`TestResult`."
msgstr ""
#: ../../library/unittest.rst:543
msgid ""
"Skipping a test is simply a matter of using the :func:`skip` :term:"
"`decorator` or one of its conditional variants, calling :meth:`TestCase."
"skipTest` within a :meth:`~TestCase.setUp` or test method, or raising :exc:"
"`SkipTest` directly."
msgstr ""
#: ../../library/unittest.rst:547
msgid "Basic skipping looks like this::"
msgstr ""
#: ../../library/unittest.rst:572
msgid "This is the output of running the example above in verbose mode::"
msgstr ""
#: ../../library/unittest.rst:584
msgid "Classes can be skipped just like methods::"
msgstr ""
#: ../../library/unittest.rst:591
msgid ""
":meth:`TestCase.setUp` can also skip the test. This is useful when a "
"resource that needs to be set up is not available."
msgstr ""
#: ../../library/unittest.rst:594
msgid "Expected failures use the :func:`expectedFailure` decorator. ::"
msgstr ""
#: ../../library/unittest.rst:601
msgid ""
"It's easy to roll your own skipping decorators by making a decorator that "
"calls :func:`skip` on the test when it wants it to be skipped. This "
"decorator skips the test unless the passed object has a certain attribute::"
msgstr ""
#: ../../library/unittest.rst:610
msgid ""
"The following decorators and exception implement test skipping and expected "
"failures:"
msgstr ""
#: ../../library/unittest.rst:614
msgid ""
"Unconditionally skip the decorated test. *reason* should describe why the "
"test is being skipped."
msgstr ""
#: ../../library/unittest.rst:619
msgid "Skip the decorated test if *condition* is true."
msgstr ""
#: ../../library/unittest.rst:623
msgid "Skip the decorated test unless *condition* is true."
msgstr ""
#: ../../library/unittest.rst:627
msgid ""
"Mark the test as an expected failure or error. If the test fails or errors "
"in the test function itself (rather than in one of the :dfn:`test fixture` "
"methods) then it will be considered a success. If the test passes, it will "
"be considered a failure."
msgstr ""
#: ../../library/unittest.rst:634
msgid "This exception is raised to skip a test."
msgstr ""
#: ../../library/unittest.rst:636
msgid ""
"Usually you can use :meth:`TestCase.skipTest` or one of the skipping "
"decorators instead of raising this directly."
msgstr ""
#: ../../library/unittest.rst:639
msgid ""
"Skipped tests will not have :meth:`~TestCase.setUp` or :meth:`~TestCase."
"tearDown` run around them. Skipped classes will not have :meth:`~TestCase."
"setUpClass` or :meth:`~TestCase.tearDownClass` run. Skipped modules will not "
"have :func:`setUpModule` or :func:`tearDownModule` run."
msgstr ""
#: ../../library/unittest.rst:647
msgid "Distinguishing test iterations using subtests"
msgstr ""
#: ../../library/unittest.rst:651
msgid ""
"When there are very small differences among your tests, for instance some "
"parameters, unittest allows you to distinguish them inside the body of a "
"test method using the :meth:`~TestCase.subTest` context manager."
msgstr ""
#: ../../library/unittest.rst:655
msgid "For example, the following test::"
msgstr ""
"舉例來說,以下測試:\n"
"\n"
"::"
#: ../../library/unittest.rst:667
msgid "will produce the following output::"
msgstr ""
"會有以下輸出:\n"
"\n"
"::"
#: ../../library/unittest.rst:699
msgid ""
"Without using a subtest, execution would stop after the first failure, and "
"the error would be less easy to diagnose because the value of ``i`` wouldn't "
"be displayed::"
msgstr ""
#: ../../library/unittest.rst:715
msgid "Classes and functions"
msgstr ""
#: ../../library/unittest.rst:717
msgid "This section describes in depth the API of :mod:`unittest`."
msgstr ""
#: ../../library/unittest.rst:723
msgid "Test cases"
msgstr ""
#: ../../library/unittest.rst:727
msgid ""
"Instances of the :class:`TestCase` class represent the logical test units in "
"the :mod:`unittest` universe. This class is intended to be used as a base "
"class, with specific tests being implemented by concrete subclasses. This "
"class implements the interface needed by the test runner to allow it to "
"drive the tests, and methods that the test code can use to check for and "
"report various kinds of failure."
msgstr ""
#: ../../library/unittest.rst:734
msgid ""
"Each instance of :class:`TestCase` will run a single base method: the method "
"named *methodName*. In most uses of :class:`TestCase`, you will neither "
"change the *methodName* nor reimplement the default ``runTest()`` method."
msgstr ""
#: ../../library/unittest.rst:739
msgid ""
":class:`TestCase` can be instantiated successfully without providing a "
"*methodName*. This makes it easier to experiment with :class:`TestCase` from "
"the interactive interpreter."
msgstr ""
#: ../../library/unittest.rst:744
msgid ""
":class:`TestCase` instances provide three groups of methods: one group used "
"to run the test, another used by the test implementation to check conditions "
"and report failures, and some inquiry methods allowing information about the "
"test itself to be gathered."
msgstr ""
#: ../../library/unittest.rst:749
msgid "Methods in the first group (running the test) are:"
msgstr ""
#: ../../library/unittest.rst:753
msgid ""
"Method called to prepare the test fixture. This is called immediately "
"before calling the test method; other than :exc:`AssertionError` or :exc:"
"`SkipTest`, any exception raised by this method will be considered an error "
"rather than a test failure. The default implementation does nothing."
msgstr ""
#: ../../library/unittest.rst:761
msgid ""
"Method called immediately after the test method has been called and the "
"result recorded. This is called even if the test method raised an "
"exception, so the implementation in subclasses may need to be particularly "
"careful about checking internal state. Any exception, other than :exc:"
"`AssertionError` or :exc:`SkipTest`, raised by this method will be "
"considered an additional error rather than a test failure (thus increasing "
"the total number of reported errors). This method will only be called if "
"the :meth:`setUp` succeeds, regardless of the outcome of the test method. "
"The default implementation does nothing."
msgstr ""
#: ../../library/unittest.rst:774
msgid ""
"A class method called before tests in an individual class are run. "
"``setUpClass`` is called with the class as the only argument and must be "
"decorated as a :func:`classmethod`::"
msgstr ""
#: ../../library/unittest.rst:782 ../../library/unittest.rst:797
msgid "See `Class and Module Fixtures`_ for more details."
msgstr "更多細節請見 `Class and Module Fixtures`_\\ 。"
#: ../../library/unittest.rst:789
msgid ""
"A class method called after tests in an individual class have run. "
"``tearDownClass`` is called with the class as the only argument and must be "
"decorated as a :meth:`classmethod`::"
msgstr ""
#: ../../library/unittest.rst:804
msgid ""
"Run the test, collecting the result into the :class:`TestResult` object "
"passed as *result*. If *result* is omitted or ``None``, a temporary result "
"object is created (by calling the :meth:`defaultTestResult` method) and "
"used. The result object is returned to :meth:`run`'s caller."
msgstr ""
#: ../../library/unittest.rst:810
msgid ""
"The same effect may be had by simply calling the :class:`TestCase` instance."
msgstr ""
#: ../../library/unittest.rst:813
msgid ""
"Previous versions of ``run`` did not return the result. Neither did calling "
"an instance."
msgstr ""
#: ../../library/unittest.rst:819
msgid ""
"Calling this during a test method or :meth:`setUp` skips the current test. "
"See :ref:`unittest-skipping` for more information."
msgstr ""
#: ../../library/unittest.rst:827
msgid ""
"Return a context manager which executes the enclosed code block as a "
"subtest. *msg* and *params* are optional, arbitrary values which are "
"displayed whenever a subtest fails, allowing you to identify them clearly."
msgstr ""
#: ../../library/unittest.rst:832
msgid ""
"A test case can contain any number of subtest declarations, and they can be "
"arbitrarily nested."
msgstr ""