Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "failed on teardown with "UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 1260: ordinal not in range(128)" #96

Open
kanagala388 opened this issue May 24, 2022 · 0 comments

Comments

@kanagala388
Copy link

kanagala388 commented May 24, 2022

Pytest version - pytest 6.2.4

While using function_scoped_container_getter argument, randomly observing the following error message. It is happening randomly for one in hundred testcases.

docker_project = <compose.project.Project object at 0x7f5b12598c18>
request = <SubRequest 'function_scoped_container_getter' for

@pytest.fixture(scope=scope)  # type: ignore
def scoped_containers_fixture(docker_project: Project, request):
    now = datetime.utcnow()
    if request.config.getoption("--use-running-containers"):
        containers = docker_project.containers()  # type: List[Container]
    else:
        if any(docker_project.containers()):
            raise ContainersAlreadyExist(
                'pytest-docker-compose tried to start containers but there are'
                ' already running containers: %s, you probably scoped your'
                ' tests wrong' % docker_project.containers())
        containers = docker_project.up()
        if not containers:
            raise ValueError("`docker-compose` didn't launch any containers!")

    container_getter = ContainerGetter(docker_project)
    yield container_getter

    if request.config.getoption("--verbose"):
        for container in sorted(containers, key=lambda c: c.name):
            header = "Logs from {name}:".format(name=container.name)
            print(header, '\n', "=" * len(header))
            print(container.logs(since=now).decode("utf-8", errors="replace")
                or "(no logs)", '\n')

E UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 1260: ordinal not in range(128)

/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pytest_docker_compose/init.py:198: UnicodeEncodeError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant