Skip to content

Exception with os.system call #284

@ivannnnnnnnnn

Description

@ivannnnnnnnnn

Hello, I am using pytest in my django application. I am write a method with call os.system function and when I run tests I catch exception

 def _update_group_permissions(self, request): group = settings.CONSTANCE_GROUP_FOR_FTP_USERS folder = settings.CONSTANCE_USER_FOLDERS # Expected .../folder_name/ try: os.system(f"chgrp {group} {folder[-1]}") os.system(f"chgrp {group} {folder}*") os.system(f"chmod 070 {folder[-1]}") os.system(f"chmod 070 {folder}*") self.message_user( request, f"Add permissions for folder to `{group}` group", level=messages.SUCCESS, ) except Exception as e: self.message_user( request, f"Failed to add permissions for group `{group}`. {str(e)}", level=messages.SUCCESS, ) 
FAILED apps/accounts/admin.py::BLACK Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pytest/__main__.py", line 7, in <module> raise SystemExit(pytest.main()) File "/usr/local/lib/python3.7/dist-packages/_pytest/config/__init__.py", line 125, in main config=config File "/usr/local/lib/python3.7/dist-packages/pluggy/hooks.py", line 286, in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) File "/usr/local/lib/python3.7/dist-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/usr/local/lib/python3.7/dist-packages/pluggy/manager.py", line 87, in <lambda> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/usr/local/lib/python3.7/dist-packages/pluggy/callers.py", line 208, in _multicall return outcome.get_result() File "/usr/local/lib/python3.7/dist-packages/pluggy/callers.py", line 80, in get_result raise ex[1].with_traceback(ex[2]) File "/usr/local/lib/python3.7/dist-packages/pluggy/callers.py", line 187, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.7/dist-packages/_pytest/main.py", line 240, in pytest_cmdline_main return wrap_session(config, _main) File "/usr/local/lib/python3.7/dist-packages/_pytest/main.py", line 229, in wrap_session session=session, exitstatus=session.exitstatus File "/usr/local/lib/python3.7/dist-packages/pluggy/hooks.py", line 286, in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) File "/usr/local/lib/python3.7/dist-packages/pluggy/manager.py", line 93, in _hookexec return self._inner_hookexec(hook, methods, kwargs) File "/usr/local/lib/python3.7/dist-packages/pluggy/manager.py", line 87, in <lambda> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, File "/usr/local/lib/python3.7/dist-packages/pluggy/callers.py", line 203, in _multicall gen.send(outcome) File "/usr/local/lib/python3.7/dist-packages/_pytest/terminal.py", line 731, in pytest_sessionfinish self.write_sep("!", session.shouldfail, red=True) File "/usr/local/lib/python3.7/dist-packages/_pytest/terminal.py", line 391, in write_sep self._tw.sep(sep, title, **markup) File "/usr/local/lib/python3.7/dist-packages/py/_io/terminalwriter.py", line 232, in sep N = max((fullwidth - len(title) - 2) // (2*len(sepchar)), 1) TypeError: object of type 'bool' has no len() make: *** [Makefile:15: test] Error 1 

If I comment part with os.system all work correctly

Test requirements:

isort==4.3.21 ipython==5.8.0 black==19.3b0 coverage==5.2.1 pytest==5.4.3 pytest-black==0.3.10 pytest-django==3.9.0 pytest-isort==1.1.0 pytest-instafail==0.4.2 pytest-blockage==0.2.2 pytest-xdist==1.34.0 django-test-plus==1.4.0 fakeredis==1.4.5 bandit==1.7.0 pytest-bandit==0.5.2 

Command for run tests:

pytest --black --ff --isort --blockage --instafail -n 0 --pdb -v 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions