Testing on edx-platform

I have a quick question about testing: I’m following the instructions here https://github.com/edx/edx-platform/blob/master/docs/guides/testing/testing.rst. I am following one of the examples written in the docs such as running the command pytest common/lib/xmodule/xmodule/tests/test_stringify.py

I am getting the below issue when testing the above command:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 143, in main
    config = _prepareconfig(args, plugins)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 319, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/helpconfig.py", line 100, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1003, in pytest_cmdline_parse
    self.parse(args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1283, in parse
    self._preparse(args, addopts=addopts)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1192, in _preparse
    early_config=self, args=args, parser=self._parser
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pluggy/callers.py", line 182, in _multicall
    next(gen)  # first yield
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/warnings.py", line 137, in pytest_load_initial_conftests
    config=early_config, ihook=early_config.hook, when="config", item=None
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/warnings.py", line 52, in catch_warnings_for_item
    apply_warning_filters(config_filters, cmdline_filters)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1603, in apply_warning_filters
    warnings.filterwarnings(*parse_warning_filter(arg, escape=False))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/config/__init__.py", line 1579, in parse_warning_filter
    category: Type[Warning] = warnings._getcategory(category_)  # type: ignore[attr-defined]
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 262, in _getcategory
    raise _OptionError("invalid module name: %r" % (module,)) from None
warnings._OptionError: invalid module name: 'xblock.exceptions'

Do I have to go through all the steps in ‘Getting Started’ listed in devstack prior to running the unit tests?

Yes, absolutely. The testing command must be run inside the LMS container, and not on the host.

Hi Regis,

Thanks for the answer! I was hoping that wasn’t the case.