I have the following directory structure.
```
$ find .
.
./app
./app/foo
./app/foo/__init__.py
./app/foo/BUILD
./app/foo/tests
./app/foo/tests/foo_test.py
./WORKSPACE
```
These are the contents of my files.
```
$ find app -type f -exec echo -- \; -print -exec cat {} \; -exec echo \;
--
app/foo/__init__.py
def bar():
return 'hello'
--
app/foo/BUILD
py_library(name = "foo", srcs = glob(["**/*.py"]))
py_test(name = "foo_test", srcs = ["tests/foo_test.py"], deps = [":foo"])
--
app/foo/tests/foo_test.py
import unittest
from foo import bar
class FooTests(unittest.TestCase):
def test_bar(self):
assert bar() == 'hello'
if __name__ == '__main__':
unittest.main()
```
This is the error.
```
$ bazel test app/foo:foo_test --verbose_failures --test_output=all
INFO: Found 1 test target...
FAIL: //app/foo:foo_test (...).
INFO: From Testing //app/foo:foo_test:
==================== Test output for //app/foo:foo_test:
Traceback (most recent call last):
File "/private/var/tmp/.../tmp/bazel-out/local-fastbuild/bin/app/foo/foo_test.runfiles/__main__/app/foo/tests/foo_test.py", line 2, in <module>
from foo import bar
ImportError: No module named foo
================================================================================
Target //app/foo:foo_test up-to-date:
bazel-bin/app/foo/foo_test
INFO: Elapsed time: 0.145s, Critical Path: 0.06s
//app/foo:foo_test FAILED in 0.1s
/private/var/tmp/.../tmp/bazel-out/local-fastbuild/testlogs/app/foo/foo_test/test.log
Executed 1 out of 1 tests: 1 fails locally.
```
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/fca2cdcc-037f-417f-ab78-c93b7ba318d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAPaFw%2Bt1Fu3N-n19g4%3D8%2BFzx%3DyOcfaikA0-xUKxuStG2paXPfQ%40mail.gmail.com.