{"id":15288995,"url":"https://github.com/lahwaacz/pytest-nginx","last_synced_at":"2025-04-13T08:12:17.250Z","repository":{"id":57456518,"uuid":"100119849","full_name":"lahwaacz/pytest-nginx","owner":"lahwaacz","description":"A pytest plugin managing an instance of the nginx web server","archived":false,"fork":false,"pushed_at":"2019-03-01T17:56:31.000Z","size":22,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T08:12:12.154Z","etag":null,"topics":["pytest","pytest-plugin","python","testing"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/pytest-nginx","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lahwaacz.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-12T15:10:34.000Z","updated_at":"2023-01-19T19:37:08.000Z","dependencies_parsed_at":"2022-09-14T05:10:23.318Z","dependency_job_id":null,"html_url":"https://github.com/lahwaacz/pytest-nginx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lahwaacz%2Fpytest-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lahwaacz%2Fpytest-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lahwaacz%2Fpytest-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lahwaacz%2Fpytest-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lahwaacz","download_url":"https://codeload.github.com/lahwaacz/pytest-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681495,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest","pytest-plugin","python","testing"],"created_at":"2024-09-30T15:55:31.832Z","updated_at":"2025-04-13T08:12:17.222Z","avatar_url":"https://github.com/lahwaacz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest-nginx\n============\n\npytest-nginx is a pytest plugin, that allows you to test code, which requires\ncommunicating with a full-fledged web server. Custom fixtures can be made which\nmanage the content of the server root directory.\n\nUsage\n=====\n\nThe plugin contains one fixture:\n\n* **nginx_proc** - session scoped fixture, which manages the nginx daemon with\n  the most basic configuration for serving static files.\n* **nginx_php_proc** - session scoped fixture, which manages the nginx daemon\n  and the php-fpm daemon, both configured to work together.\n\nAll fixtures take the name of a fixture managing the server root directory. In\nthe simplest case it is an empty temporary directory managed with the\n``tmpdir_factory`` built-in fixture:\n\n.. code-block:: python\n\n    from pytest_nginx import factories\n    \n    @pytest.fixture(scope=\"session\")\n    def nginx_server_root(tmpdir_factory):\n        return tmpdir_factory.mktemp(\"nginx-server-root\")\n    \n    nginx_proc = factories.nginx_proc(\"nginx_server_root\")\n\nTo manage the served content, you can create additional module or\nfunction-scoped fixtures on top of ``nginx_proc``:\n\n.. code-block:: python\n\n    @pytest.fixture(scope=\"module\")\n    def nginx_hello_world(nginx_proc):\n        f = open(os.path.join(nginx_proc.server_root, \"index.html\"), \"w\")\n        f.write(\"Hello world! This is pytest-nginx serving on host {}, port {}.\"\n                .format(nginx_proc.host, nginx_proc.port))\n        f.close()\n        return nginx_proc\n\nConfiguration\n=============\n\nYou can define your settings in three ways: with fixture factory arguments,\nwith command line options and with ``pytest.ini`` configuration options. These\nsettings are handled in the following order:\n\n1. Fixture factory arguments\n2. Command line options\n3. ``pytest.ini`` configuration options\n\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| Fixture factory argument  | Command line option       | pytest.ini option         | Default                   |\n+===========================+===========================+===========================+===========================+\n| host                      | --nginx-host              | nginx_host                | 127.0.0.1                 |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| port                      | --nginx-port              | nginx_port                | random                    |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| nginx_exec                | --nginx-exec              | nginx_exec                | nginx                     |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| nginx_params              | --nginx-params            | nginx_params              | \"\"                        |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| nginx_config_template     | --nginx-config-template   | nginx_config_template     | auto-generated            |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| php_fpm_exec              | --php-fpm-exec            | php_fpm_exec              | php-fpm                   |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| php_fpm_params            | --php-fpm-params          | php_fpm_params            | \"\"                        |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n| php_fpm_config_template   | --php-fpm-config-template | php_fpm_config_template   | auto-generated            |\n+---------------------------+---------------------------+---------------------------+---------------------------+\n\nExamples showing how to specify the port number:\n\n* Pass it as an argument to the factory function:\n\n  .. code-block:: python\n\n        nginx_proc = factories.nginx_proc(port=8888)\n\n* Use the ``--nginx-port`` command line option when running pytest:\n\n  .. code-block::\n\n        pytest ./tests --nginx-port=8888\n\n\n* Add the ``nginx_port`` option to the ``pytest.ini`` file:\n\n  .. code-block:: ini\n\n        [pytest]\n        nginx_port = 8888\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flahwaacz%2Fpytest-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flahwaacz%2Fpytest-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flahwaacz%2Fpytest-nginx/lists"}