# Unable to run python tests - No module named beat.beat

**URL:** <https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949>\
**Category:** Beats\
**Tags:** beats-development\
**Created:** [September 25, 2020, 9:54am UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949 "2020-09-25T09:54:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebanashka](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@ebanashka](https://discuss.elastic.co/u/ebanashka)\
**Post date:** [September 25, 2020, 9:54am UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949/1 "2020-09-25T09:54:14Z")

</div>

I am unable to run python tests for packetbeat or any other beats.  
Here's what I've done:

1. in the packetbeat dir i ran `make python-dev`
2. then navigated to the tests/system folder and ran `nosetests -x -v`. Getting the following error:

```auto
❯ nosetests -x -v
Failure: ImportError (No module named beat.beat) ... ERROR

======================================================================
ERROR: Failure: ImportError (No module named beat.beat)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home//Projects/beats/packetbeat/tests/system/test_0001_mysql_spaces.py", line 1, in <module>
    from packetbeat import BaseTest
  File "/home//Projects/beats/packetbeat/tests/system/packetbeat.py", line 5, in <module>
    from beat.beat import TestCase
ImportError: No module named beat.beat

```

In addition to that python code navigation does not work in either intellij or vscode for same reason:

```auto
❯ /home//Projects/beats/packetbeat/build/python-env/bin/python3 /home//Projects/beats/packetbeat/tests/system/test_0005_mysql_integration.py
Traceback (most recent call last):
  File "/home//Projects/beats/packetbeat/tests/system/test_0005_mysql_integration.py", line 1, in <module>
    from packetbeat import BaseTest
  File "/home//Projects/beats/packetbeat/tests/system/packetbeat.py", line 5, in <module>
    from beat.beat import TestCase
ModuleNotFoundError: No module named 'beat'

```

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [September 25, 2020, 2:20pm UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949/2 "2020-09-25T14:20:15Z")

</div>

Beats is not using `nosetests` anymore. We have adopted `pytest` instead.

This is how I usually run tests:

```auto
python3 -m pytest tests/system/test_base.py --verbose

```

Let me know if you still have issues.

---

<div class="post-metadata">

**Author:** ![ebanashka](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@ebanashka](https://discuss.elastic.co/u/ebanashka)\
**Post date:** [September 26, 2020, 8:44am UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949/3 "2020-09-26T08:44:11Z")

</div>

Hi

Thanks.

Now getting a different error -

```auto
FileNotFoundError: [Errno 2] No such file or directory: '/home//Projects/beats/packetbeat/packetbeat.test'

/usr/lib/python3.8/subprocess.py:1702: FileNotFoundError
===================================================== short test summary info =====================================================
FAILED tests/system/test_base.py::Test::test_export_config - FileNotFoundError: [Errno 2] No such file or directory: '/home/dmit...
FAILED tests/system/test_base.py::Test::test_export_ilm_policy - FileNotFoundError: [Errno 2] No such file or directory: '/home/...
FAILED tests/system/test_base.py::Test::test_export_index_pattern - FileNotFoundError: [Errno 2] No such file or directory: '/ho...
FAILED tests/system/test_base.py::Test::test_export_index_pattern_migration - FileNotFoundError: [Errno 2] No such file or direc...
FAILED tests/system/test_base.py::Test::test_export_template - FileNotFoundError: [Errno 2] No such file or directory: '/home/...
=========================================

```

---

<div class="post-metadata">

**Author:** ![ebanashka](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@ebanashka](https://discuss.elastic.co/u/ebanashka)\
**Post date:** [September 26, 2020, 9:54am UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949/4 "2020-09-26T09:54:51Z")

</div>

Ran `go test -c` and it created `packetbeat.test`. Would be nice to have all of this in the documentation ☹

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2020, 11:54am UTC](https://discuss.elastic.co/t/unable-to-run-python-tests-no-module-named-beat-beat/249949/5 "2020-10-24T11:54:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
