Reputation: 2094
In a source code in python: usr/local/lib/python3.3/unittest/__init__.py
from .result import TestResult
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
skipUnless, expectedFailure)
from .suite import BaseTestSuite, TestSuite
from .loader import (TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,
findTestCases)
from .main import TestProgram, main
from .runner import TextTestRunner, TextTestResult
from .signals import installHandler, registerResult, removeResult, removeHandler
I can't understand .result
and .main
. Why do they have a dot prefix in the name?
Upvotes: 3
Views: 669
Reputation: 26582
You are importing main
module which is in the same package that your file, you are doing a relative import (dot prefix). More on relative imports on PEP 328
Upvotes: 0
Reputation: 597203
It's called a relative import.
It means you import from the module in the same directory that the module this code is in. Without the dot, it would import the from first module found in the PYTHON PATH.
Upvotes: 6