Skip to content

Commit

Permalink
Merge pull request #276 from pv/fix-benchmark-sys-path
Browse files Browse the repository at this point in the history
Ensure benchmark.py script doesn't have asv package directory in sys.path
  • Loading branch information
pv committed Jun 16, 2015
2 parents 72953a6 + 45c99c1 commit 7fbc7e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion asv/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +31,6 @@
import json
import os
import re
import sys
import textwrap
import timeit
import itertools
Expand Down
11 changes: 11 additions & 0 deletions test/benchmark/time_secondary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7fbc7e9

Please sign in to comment.