man-group / man-group/pytest-plugins

pytest-pyramid-server hostname error

Open
#143 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

fixed-confirm
Dominant language
Python
Stars
597
Forks
89
PR merge metrics
No merged PRs in 30d

Description

I just installed this package to test a pyramid project, and I'm getting the following error:

```python
def test_pyramid_server(pyramid_server):
assert pyramid_server.dead is False
assert pyramid_server.uri.startswith('http')

assert pyramid_server.working_config.endswith('testing.ini')
```

Output goes:

```
======================================== ERRORS =========================================
_________________________ ERROR at setup of test_pyramid_server _________________________

request = >

@yield_fixture(scope='session')
def pyramid_server(request):
""" Session-scoped Pyramid server run in a subprocess, out of a temp dir.
This is a 'real' server that you can point a Selenium webdriver at.

This fixture searches for its configuration in the current working directory
called 'testing.ini'. All .ini files in the cwd will be copied to the tempdir
so that config chaining still works.

The fixture implementation in `PyramidTestServer` has more flexible configuration
options, use it directly to define more fine-grained fixtures.

Methods
-------
get_config() : Return current configuration as a dict.
get() : Query url relative to the server root.
.. Retry failures by default.
post() : Post payload to url relative to the server root.
.. Retry failures by default.

Attributes
----------
working_config (`path.path`): Path to the config file used by the server at runtime
.. also inherits all attributes from the `workspace` fixture
"""
> with PyramidTestServer() as server:

.env/lib/python3.6/site-packages/pytest_pyramid_server.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = , config_dir = None
config_filename = None, extra_config_vars = None, kwargs = {}

def __init__(self, config_dir=None, config_filename=None, extra_config_vars=None, **kwargs):
""" Test server for a Pyramid project

Parameters
----------
config_dir:
Path to a directory to find the config file/s. Defaults to current working dir, and
all .ini files in the directory will be made available for config file chaining.
config_filename:
Name of the main config file to use. Defaults to testing.ini.
extra_config_vars:
Dict of any extra entries to add to the file, as { section: { key: value } }
"""
self.extra_config_vars = extra_config_vars if extra_config_vars is not None else {}
self.config_dir = config_dir if config_dir is not None else os.getcwd()
self.config_filename = config_filename if config_filename else 'testing.ini'

self.working_config = None
self.original_config = Path(self.config_dir) / self.config_filename

# Always print debug output for this process
os.environ['DEBUG'] = '1'

# Discover externally accessable hostname so selenium can get to it
> kwargs['hostname'] = kwargs.get('hostname', socket.gethostbyname(os.uname()[1]))
E socket.gaierror: [Errno 8] nodename nor servname provided, or not known

.env/lib/python3.6/site-packages/pytest_pyramid_server.py:87: gaierror
=================================== warnings summary ====================================
.env/lib/python3.6/site-packages/venusian/__init__.py:1
/Users/ppeixoto/Projects/wellwatcher_api/.env/lib/python3.6/site-packages/venusian/__init__.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============== 15 passed, 3 skipped, 1 warnings, 1 error in 4.49 seconds ===============
```

It seems the issue is related to a hostname not being passed as a parameter to the PyramidTestServer object, and also failing to be obtained by name resolution.

Related to #127

Now I'm not sure something is missing on my system, but it's clearly usable, as I'm working on it. It also does not seem very straightforward that a python lib should require a hostname being set on the machine.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at PyramidTestServer.__init__ in the pytest_pyramid_server.py traceback and reproduce the failure around socket.gethostbyname(os.uname()[1]). Compare the behavior with related issue #127 and verify the server fixture still starts successfully on a machine whose hostname cannot be resolved, while preserving the existing hostname parameter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.