diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-18 07:19:46 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 07:19:46 +0000 |
commit | 869b5967fcf4bfd481fe0928d1aa9ffbbd12a67e (patch) | |
tree | 320c79984e7fd870a41ecf99542d05709b8919dd | |
parent | 2d6ef933b7f32ddfe7abd08d85be701702a2fb84 (diff) |
automatic import of python-pytest-network
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-pytest-network.spec | 336 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 338 insertions, 0 deletions
@@ -0,0 +1 @@ +/pytest_network-0.0.1.tar.gz diff --git a/python-pytest-network.spec b/python-pytest-network.spec new file mode 100644 index 0000000..56c9fba --- /dev/null +++ b/python-pytest-network.spec @@ -0,0 +1,336 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pytest-network +Version: 0.0.1 +Release: 1 +Summary: A simple plugin to disable network on socket level. +License: MIT +URL: https://github.com/best-doctor/pytest_network +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8c/f2/2b381c56e0dbc7404fb104277bc731865786db7c005351441561ec1a9e25/pytest_network-0.0.1.tar.gz +BuildArch: noarch + + +%description +# pytest-network + +[](https://travis-ci.org/best-doctor/pytest_network) +[](https://codeclimate.com/github/best-doctor/pytest_network/maintainability) +[](https://codeclimate.com/github/best-doctor/pytest_network/test_coverage) + +A simple pytest plugin to disable network on socket level. + +## Installation + +`$ pip install pytest-network` + +## Usage + +`pytest-network` has a flag `--disable-network` that will raise an error +if tests will try to use `socket.socket.connect` + +You can use it directly like: + +`$ python3 -m pytest --disable-network` + +or add this flag as the default behavior in your `pytest.ini`: + +```ini +[pytest] +addopts = --disable-network +``` + +Also you can directly disable network: + +```python3 +import requests + + +def test_network_request_raises_error(disable_network): + response = requests.get('https://github.com') # this will raise an exception + + assert response.status_code == 200 +``` + +or directly enable (if you have default `--disable-network` flag): + +```python3 +import requests + + +def test_network_request_is_ok(disable_network): + response = requests.get('https://github.com') + + assert response.status_code == 200 # this will pass +``` + +## Development + +To setup development environment you must first create a virtual environment. +For example: + +`$ python3.8 -m venv <venv-name>` + +After that install all requirements: + +`$ pip install -r requirements.txt` + +And install plugin itself (inside project directory and virtual environment): + +`$ pip install -e .` + +Check that tests are running: + +`$ make test` + +## Contributing + +We would love you to contribute to our project. It's simple: + +* Create an issue with bug you found or proposal you have. + Wait for approve from maintainer. +* Create a pull request. Make sure all checks are green. +* Fix review comments if any. +* Be awesome. + +Here are useful tips: + +* You can run all checks and tests with make check. + Please do it before TravisCI does. +* We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). + Sorry, styleguide is available only in Russian for now. +* We respect [Django CoC](https://www.djangoproject.com/conduct/). + Make soft, not bullshit. + +%package -n python3-pytest-network +Summary: A simple plugin to disable network on socket level. +Provides: python-pytest-network +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pytest-network +# pytest-network + +[](https://travis-ci.org/best-doctor/pytest_network) +[](https://codeclimate.com/github/best-doctor/pytest_network/maintainability) +[](https://codeclimate.com/github/best-doctor/pytest_network/test_coverage) + +A simple pytest plugin to disable network on socket level. + +## Installation + +`$ pip install pytest-network` + +## Usage + +`pytest-network` has a flag `--disable-network` that will raise an error +if tests will try to use `socket.socket.connect` + +You can use it directly like: + +`$ python3 -m pytest --disable-network` + +or add this flag as the default behavior in your `pytest.ini`: + +```ini +[pytest] +addopts = --disable-network +``` + +Also you can directly disable network: + +```python3 +import requests + + +def test_network_request_raises_error(disable_network): + response = requests.get('https://github.com') # this will raise an exception + + assert response.status_code == 200 +``` + +or directly enable (if you have default `--disable-network` flag): + +```python3 +import requests + + +def test_network_request_is_ok(disable_network): + response = requests.get('https://github.com') + + assert response.status_code == 200 # this will pass +``` + +## Development + +To setup development environment you must first create a virtual environment. +For example: + +`$ python3.8 -m venv <venv-name>` + +After that install all requirements: + +`$ pip install -r requirements.txt` + +And install plugin itself (inside project directory and virtual environment): + +`$ pip install -e .` + +Check that tests are running: + +`$ make test` + +## Contributing + +We would love you to contribute to our project. It's simple: + +* Create an issue with bug you found or proposal you have. + Wait for approve from maintainer. +* Create a pull request. Make sure all checks are green. +* Fix review comments if any. +* Be awesome. + +Here are useful tips: + +* You can run all checks and tests with make check. + Please do it before TravisCI does. +* We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). + Sorry, styleguide is available only in Russian for now. +* We respect [Django CoC](https://www.djangoproject.com/conduct/). + Make soft, not bullshit. + +%package help +Summary: Development documents and examples for pytest-network +Provides: python3-pytest-network-doc +%description help +# pytest-network + +[](https://travis-ci.org/best-doctor/pytest_network) +[](https://codeclimate.com/github/best-doctor/pytest_network/maintainability) +[](https://codeclimate.com/github/best-doctor/pytest_network/test_coverage) + +A simple pytest plugin to disable network on socket level. + +## Installation + +`$ pip install pytest-network` + +## Usage + +`pytest-network` has a flag `--disable-network` that will raise an error +if tests will try to use `socket.socket.connect` + +You can use it directly like: + +`$ python3 -m pytest --disable-network` + +or add this flag as the default behavior in your `pytest.ini`: + +```ini +[pytest] +addopts = --disable-network +``` + +Also you can directly disable network: + +```python3 +import requests + + +def test_network_request_raises_error(disable_network): + response = requests.get('https://github.com') # this will raise an exception + + assert response.status_code == 200 +``` + +or directly enable (if you have default `--disable-network` flag): + +```python3 +import requests + + +def test_network_request_is_ok(disable_network): + response = requests.get('https://github.com') + + assert response.status_code == 200 # this will pass +``` + +## Development + +To setup development environment you must first create a virtual environment. +For example: + +`$ python3.8 -m venv <venv-name>` + +After that install all requirements: + +`$ pip install -r requirements.txt` + +And install plugin itself (inside project directory and virtual environment): + +`$ pip install -e .` + +Check that tests are running: + +`$ make test` + +## Contributing + +We would love you to contribute to our project. It's simple: + +* Create an issue with bug you found or proposal you have. + Wait for approve from maintainer. +* Create a pull request. Make sure all checks are green. +* Fix review comments if any. +* Be awesome. + +Here are useful tips: + +* You can run all checks and tests with make check. + Please do it before TravisCI does. +* We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). + Sorry, styleguide is available only in Russian for now. +* We respect [Django CoC](https://www.djangoproject.com/conduct/). + Make soft, not bullshit. + +%prep +%autosetup -n pytest-network-0.0.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pytest-network -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.1-1 +- Package Spec generated @@ -0,0 +1 @@ +ff90ac6c57611f1fa4a4d651fe074a3f pytest_network-0.0.1.tar.gz |