diff --git a/asv/benchmark.py b/asv/benchmark.py index 2e3225976..dd92f6df6 100644 --- a/asv/benchmark.py +++ b/asv/benchmark.py @@ -12,6 +12,12 @@ # the Python standard library. This is the only bit of code from asv # that is imported into the benchmarking process. +# Remove asv package directory from sys.path. This script file resides +# there although it's not part of the package, and Python puts it to +# sys.path[0] on start which can shadow other modules +import sys +sys.path.pop(0) + import copy try: import cProfile as profile @@ -25,7 +31,6 @@ import json import os import re -import sys import textwrap import timeit import itertools diff --git a/test/benchmark/time_secondary.py b/test/benchmark/time_secondary.py index a973fdf8b..4bd91ea0d 100644 --- a/test/benchmark/time_secondary.py +++ b/test/benchmark/time_secondary.py @@ -9,8 +9,19 @@ xrange = range +# Test that local imports work from .shared import shared_function +# Test that asv's internal modules aren't visible on top level +if sys.version_info[0] < 3: + import commands +try: + import commands.quickstart + assert False +except ImportError: + # OK + pass + class TimeSecondary: goal_time = 0.05