pycsw 2.0-dev - en to zh translation catalogue (74 entries)

en: Testing
zh: 测试

en: Pycsw uses `pytest`_ for managing its automated tests. There are a number of test suites that perform mostly functional testing. These tests ensure that pycsw is compliant with the various supported standards. There is also a growing set of unit tests. These focus on smaller scope testing, in order to verify that individual bits of code are working as expected.
zh: Pycsw使用 `pytest`_ 管理它的自动化测试。有许多测试套件主要执行功能测试。这些测试确保pycsw符合各种受支持的标准。还有一组不断增长的单元测试。这些测试集中在较小的范围内，以便验证各个代码位是否按预期工作.

en: Tests can be run locally as part of the development cycle. They are also run on pycsw's `Travis`_ continuous integration server against all pushes and pull requests to the code repository.
zh: 测试可以作为开发周期的一部分在本地运行。它们还运行在pycsw的 `Travis`_ continuous integration服务器上，用于处理所有对代码存储库的推拉请求.

en: OGC CITE
zh: OGC引用

en: In addition to pycsw's own tests, all public releases are also tested via the OGC `Compliance & Interoperability Testing & Evaluation Initiative`_ (CITE). The pycsw `wiki`_ documents CITE testing procedures and status.
zh: 除了pycsw自己的测试，所有的公共版本也通过OGC的 `Compliance & Interoperability Testing & Evaluation Initiative`_ (CITE)进行测试。pycsw `wiki`_ 文档CITE 引用了测试过程和状态.

en: Functional test suites
zh: 功能测试套件

en: Currently most of pycsw's tests are `functional tests`_. This means that each test case is based on the requirements mandated by the specifications of the various standards that pycsw implements. These tests focus on making sure that pycsw works as expected.
zh: 目前大多数pycsw的测试都是 `functional tests`_ 。这意味着每个测试用例都基于pycsw实现的各种标准的规范所规定的需求。这些测试的重点是确保 pycsw按预期的那样工作.

en: Each test follows the same workflow:
zh: 每个测试遵循相同的工作流程:

en: Create a new pycsw instance with a custom configuration and data repository for each suite of tests;
zh: 为每个测试套件创建一个新的pycsw实例，该实例具有自定义配置和数据存储库;

en: Perform a series of GET and POST requests to the running pycsw instance;
zh: 对运行的pycsw 实例执行一系列GET和POST请求;

en: Compare the results of each request against a previously prepared expected result. If the test result matches the expected outcome the test passes, otherwise it fails.
zh: 将每个请求的结果与预先准备的预期结果进行比较。如果测试结果与预期结果一致，则测试通过，否则失败.

en: A number of different test suites exist under ``tests/functionaltests/suites``. Each suite specifies the following structure:
zh: 在 ``tests/functionaltests/suites`` 下存在许多不同的测试套件。每个套件指定以下结构:

en: A mandatory ``default.cfg`` file with the pycsw configuration that must be used by the test suite;
zh: 必须由测试套件使用的具有pycsw配置的强制 ``default.cfg`` ;

en: A mandatory ``expected/`` directory containing the expected results for each request;
zh: 包含每个请求的预期结果的强制性 ``expected/`` 目录;

en: An optional ``data/`` directory that contains ``.xml`` files with testing data that is to be loaded into the suite's database before running the tests. The presence of this directory and its contents have the following meaning for tests:
zh: 一个可选的 ``data/`` 目录，包含 ``.xml`` 文件，其中包含要在运行测试之前加载到套件数据库中的测试数据。该目录及其内容的存在对测试具有以下意义:

en: If ``data/`` directory is present and contains files, they will be loaded into a new database for running the tests of the suite;
zh: 如果 ``data/`` 目录存在并且包含文件，它们将被加载到一个新的数据库中，用于运行套件的测试;

en: If ``data/`` directory is present and does not contain any data files, a new empty database is used in the tests;
zh: 如果存在 ``data/`` 目录并且不包含任何数据文件，则在测试中使用新的空数据库;

en: If ``data/`` directory is absent, the suite will use a database populated with test data from the ``CITE`` suite.
zh: 如果 ``data/`` 目录不存在，套件将使用填充有 ``CITE`` 套件的测试数据的数据库.

en: An optional ``get/requests.txt`` file that holds request parameters used for making HTTP GET requests.
zh: 一个可选的 ``get/requests.txt`` 文件，其中保存用于生成HTTP GET请求的请求参数.

en: Each line in the file must be formatted with the following scheme:
zh: 文件中的每一行必须用以下方案格式化:

en: For example:
zh: 例如：

en: When tests are run, the *test_id* is used for naming each test and for finding the expected result.
zh: 当测试运行时， *test_id* 用于命名每个测试并寻找预期结果.

en: An optional ``post/`` directory that holds ``.xml`` files used for making HTTP POST requests
zh: 一个可选的 ``post/`` 目录，它包含用于制作HTTP POST请求的 ``.xml`` 文件

en: Test identifiers
zh: 测试标识符

en: Each test has an identifier that is built using the following rule:
zh: 每个测试都有一个标识符，该标识符是使用以下规则构建的:

en: Functional tests are generated for each suite directory present under `tests/functionaltests/suites`. Test generation uses pytest's `pytest_generate_tests`_ function. This function is implemented in `tests/functionaltests/conftest.py`. It provides an automatic parametrization of the `tests/functionaltests/test_suites_functional:test_suites` function. This parametrization causes the generation of a test for each of the GET and POST requests defined in a suite's directory.
zh: 对 `tests/functionaltests/suites` 下出现的每个套件目录生成功能测试。测试生成使用pytest's `pytest_generate_tests`_ 功能。这个功能在 `tests/functionaltests/conftest.py` 中实现。它提供了 `tests/functionaltests/test_suites_functional:test_suites` 功能的自动参数化。此参数化导致为套件目录中定义的每个 GET 和 POST 请求生成测试.

en: Adding New Tests
zh: 添加新测试

en: To add tests to an existing suite:
zh: 在现有套件中添加测试：

en: for HTTP POST tests, add XML documents to ``tests/functionaltests/suites/<suite>/post``
zh: 对于HTTP POST测试，在 ``tests/functionaltests/suites/<suite>/post`` 添加XML文档

en: for HTTP GET tests, add tests (one per line) to ``tests/functionaltests/suites/<suite>/get/requests.txt``
zh: 对于HTTP GET测试，在 ``tests/functionaltests/suites/<suite>/get/requests.txt`` 中添加测试（每行的第一项）

en: To add a new test suite:
zh: 添加新的测试套件：

en: Create a new directory under ``tests/functionaltests/suites`` (e.g. ``foo``)
zh: 在 ``tests/functionaltests/suites`` （如 ``foo`` )下创建一个新目录

en: Create a new configuration in ``tests/suites/foo/default.cfg``
zh: 在 ``tests/suites/foo/default.cfg`` 创建一个新的配置

en: Populate HTTP POST requests in ``tests/suites/foo/post``
zh: 在 ``tests/suites/foo/post`` 填写HTTP POST请求

en: Populate HTTP GET requests in ``tests/suites/foo/get/requests.txt``
zh: 在 ``tests/suites/foo/get/requests.txt`` 填写HTTP GET请求

en: If the test suite requires test data, create ``tests/suites/foo/data`` and store XML files there. These will be inserted in the test catalogue at test runtime
zh: 如果需要测试组件的测试数据，创建 ``tests/suites/foo/data``，以存储XML文件。这会在运行时插入到测试目录

en: Use pytest or tox as described above in order to run the tests
zh: 使用如上所述的pytest或者 tox来运行测试

en: The new test suite database will be created automatically and used as part of tests.
zh: 新的测试套件数据库将自动创建，并且会成为测试的一部分。

en: Unit tests
zh: 单元测试

en: pycsw also features unit tests. These deal with testing the expected behaviour of individual functions.
zh: pycsw还具有单元测试。这些用于处理测试单个功能的预期行为.

en: The usual implementation of unit tests is to import the function/method under test, run it with a set of known arguments and assert that the result matches the expected outcome.
zh: 单元测试的通常实现是导入被测试的功能/方法，用一组已知的参数运行它，并断言结果与预期结果匹配.

en: Unit tests are defined in `pycsw/tests/unittests/<module_name>`.
zh: Unit tests are defined in  `pycsw/tests/unittests/<module_name>`.

en: pycsw's unit tests are marked with the `unit` marker. This makes it easy to run them in isolation:
zh: pycsw的单元测试用 `unit` 来标记。这使得它们很容易单独运行:

en: Running tests
zh: 运行测试

en: Since pycsw uses `pytest`_, tests are run with the ``py.test`` runner. A basic test run can be made with:
zh: 由于pycsw使用 `pytest`_，所以测试是用 ``py.test`` runner运行的。一个基本的测试运行可以用：

en: This command will run all tests and report on the number of successes, failures and also the time it took to run them. The `py.test` command accepts several additional parameters that can be used in order to customize the execution of tests. Look into `pytest's invocation documentation`_ for a more complete description. You can also get a description of the available parameters by running:
zh: 这个命令将运行所有测试，并报告成功、失败次数以及运行它们所花费的时间。 `py.test` 命令接受几个额外的参数，这些参数可用于自定义测试的执行。查看 `pytest's invocation documentation`_，以获得更完整的描述。您还可以通过运行来获得可用参数的描述：

en: Running specific suites and test cases
zh: 运行特定套件和测试用例

en: py.test allows tagging tests with markers. These can be used to selectively run some tests. pycsw uses two markers:
zh: py.test 允许标记测试。这些可以用来选择性地运行一些测试。 pycsw 使用两个标记：

en: ``unit`` - run only inut tests
zh: ``unit`` - 只运行inut测试

en: ``functional``- run onyl functional tests
zh: ``functional``- 只运行功能测试

en: Markers can be specified by using the ``-m <marker_name>`` flag.
zh: 标记可以通过使用 ``-m <marker_name>`` 标志来指定.

en: You can also use the ``-k <name_expression>`` flag to select which tests to run. Since each test's name includes the suite name, http method and an identifier for the test, it is easy to run only certain tests.
zh: 您还可以使用 ``-k <name_expression>`` 标志来选择要运行哪些测试。由于每个测试的名称都包含套件名称、http方法和测试的标识符，因此仅运行某些测试很容易.

en: The ``-m`` and ``-k`` flags can be combined.
zh: ``-m`` and ``-k`` 标志可以组合起来.

en: Exiting fast
zh: 快速退出

en: The ``--exitfirst`` (or ``-x``) flag can be used to stop the test runner immediately as soon as a test case fails.
zh: ``--exitfirst`` (or ``-x`` ) 标志可用于在测试用例失败时立即停止测试运行程序.

en: Seeing more output
zh: 看到更多的输出

en: There are three main ways to get more output from running tests:
zh: 从运行测试中获得更多输出的主要方法有三种:

en: The ``--verbose`` (or ``-v``) flag;
zh: ``--verbose`` (or ``-v`` ) 标志;

en: The ``--capture=no`` flag - Messages sent to stdout by a test are not suppressed;
zh: 测试发送到stdout的 ``--capture=no``  flag - Messages不会被抑制;

en: The ``--pycsw-loglevel`` flag - Sets the log level of the pycsw instance under test. Set this value to ``debug`` in order to see all debug messages sent by pycsw while processing a request.
zh: ``--pycsw-loglevel`` 标志 - 设置被测试的pycsw实例的日志级别。将此值设置为 ``debug`` ，以便查看pycsw在处理请求时发送的所有调试消息.

en: Comparing results with difflib instead of XML c14n
zh: 将结果与difflib而不是XML c14n进行比较

en: The functional tests compare results with their expected values by using [XML canonicalisation - XML c14n](https://www.w3.org/TR/xml-c14n/). Alternatively, you can call py.test with the ``--functional-prefer-diffs`` flag. This will enable comparison based on Python's ``difflib``. Comparison is made on a line-by-line basis and in case of failure, a unified diff will be printed to standard output.
zh: 功能测试使用 [XML canonicalisation - XML c14n](https://www.w3.org/TR/xml-c14n/) 将结果与期望值进行比较。或者，也可以调用py, 使用 ``--functional-prefer-diffs`` 标志进行测试。这将支持基于 Python's ``difflib`` 的比较。在逐行比较的基础上，如果失败,将把统一的差异打印到标准输出.

en: Saving test results for disk
zh: 在磁盘中保存测试结果

en: The result of each functional test can be saved to disk by using the ``--functional-save-results-directory`` option. Each result file is named after the test identifier it has when running with pytest.
zh: 通过使用 ``--functional-save-results-directory`` 选项，可以将每个功能测试的结果保存到磁盘上。每个结果文件都是根据使用pytest运行时的测试标识符命名的.

en: Test coverage
zh: 测试覆盖率

en: Use the `--cov pycsw` flag in order to see information on code coverage. It is possible to get output in a variety of formats.
zh: 使用 `--cov pycsw` 标志来查看代码覆盖率的信息。可以以各种格式获得输出.

en: Specifying a timeout for tests
zh: 指定测试超时

en: The `--timeout <seconds>` option can be used to specify that if a test takes more than `<seconds>` to run it is considered to have failed. Seconds can be a float, so it is possibe to specify sub-second timeouts
zh: `--timeout <seconds>` 选项可用于指定如果测试运行时间超过 `<seconds>`，则认为它已经失败。秒可以是一个浮点，所以可以指定次秒超时

en: Use the `--flake8` flag to also check if the code complies with Python's style guide
zh: 使用 `--flake8` 标志也检查代码是否符合Python风格指南

en: Testing multiple Python versions
zh: 测试多个Python版本

en: For testing multiple Python versions and configurations simultaneously you can use `tox`_. pycsw includes a `tox.ini` file with a suitable configuration. It can be used to run tests against multiple Python versions and also multiple database backends. When running `tox` you can send arguments to the `py.test` runner by using the invocation `tox <tox arguments> -- <py.test arguments>`. Examples:
zh: 为了同时测试多个Python版本和配置，可以使用 `tox`_ 。 pycsw包含一个具有适当配置的 `tox.ini` 文件它可以用于对多个Python版本和多个数据库后端进行测试。在运行 `tox` 时，可以通过调用 `tox <tox arguments> -- <py.test arguments>` 向 `py.test` 运行程序发送参数。例如：

en: Web Testing
zh: Web测试

en: You can also use the pycsw tests via your web browser to perform sample requests against your pycsw install.  The tests are is located in ``tests/``.  To generate the HTML page:
zh: 您还可以通过Web浏览器使用pycsw测试，来执行你的pycsw安装样例申请。这些测试在 ``tests/`` 中。生成HTML页面：

en: Then navigate to ``http://host/path/to/pycsw/tests/index.html``.
zh: 然后导航到 ``http://host/path/to/pycsw/tests/index.html`` 。
