diff --git a/tests/master_test.py b/tests/master_test.py
index <HASH>..<HASH> 100644
--- a/tests/master_test.py
+++ b/tests/master_test.py
@@ -1,3 +1,4 @@
+import inspect
 
 import unittest2
 
@@ -9,8 +10,10 @@ class ScanCodeImportsTest(unittest2.TestCase):
     func = staticmethod(mitogen.master.scan_code_imports)
 
     def test_simple(self):
-        co = compile(open(__file__).read(), __file__, 'exec')
+        source_path = inspect.getsourcefile(ScanCodeImportsTest)
+        co = compile(open(source_path).read(), source_path, 'exec')
         self.assertEquals(list(self.func(co)), [
+            (-1, 'inspect', ()),
             (-1, 'unittest2', ()),
             (-1, 'testlib', ()),
             (-1, 'mitogen.master', ()),
master_test: Don't assume __file__ points to source code

When run under a test runner the unit tests are imported as modules.
This triggers .pyc generation, after which __file__ resolves to the .pyc
file.