From aa189dd4deb5327e87d9458dd92508a38208c807 Mon Sep 17 00:00:00 2001 From: dongweiming <61966225@qq.com> Date: Tue, 12 Mar 2013 18:41:44 +0800 Subject: [PATCH] Modify sensei display the information in the directory of python2 / 3, the remaining number of courses error. the glob module to get the user to execute the current directory, rather than where the program directory --- python2/runner/sensei.py | 6 ++++-- python3/runner/sensei.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python2/runner/sensei.py b/python2/runner/sensei.py index bf8b93898..95703c024 100644 --- a/python2/runner/sensei.py +++ b/python2/runner/sensei.py @@ -4,6 +4,7 @@ import unittest import re import sys +import os import glob import helper @@ -235,6 +236,7 @@ def say_something_zenlike(self): def total_lessons(self): all_lessons = self.filter_all_lessons() + if all_lessons: return len(all_lessons) else: @@ -244,10 +246,10 @@ def total_koans(self): return self.tests.countTestCases() def filter_all_lessons(self): + cur_dir = os.path.split(os.path.realpath(__file__))[0] if not self.all_lessons: - self.all_lessons = glob.glob('koans/about*.py') + self.all_lessons = glob.glob('{0}/../koans/about*.py'.format(cur_dir)) self.all_lessons = filter(lambda filename: "about_extra_credit" not in filename, self.all_lessons) - return self.all_lessons diff --git a/python3/runner/sensei.py b/python3/runner/sensei.py index 3c6692be4..2ffbbaeb4 100644 --- a/python3/runner/sensei.py +++ b/python3/runner/sensei.py @@ -3,6 +3,7 @@ import unittest import re +import os import glob from . import helper @@ -243,8 +244,9 @@ def total_koans(self): return self.tests.countTestCases() def filter_all_lessons(self): + cur_dir = os.path.split(os.path.realpath(__file__))[0] if not self.all_lessons: - self.all_lessons = glob.glob('koans/about*.py') + self.all_lessons = glob.glob('{0}/../koans/about*.py'.format(cur_dir)) self.all_lessons = list(filter(lambda filename: "about_extra_credit" not in filename, self.all_lessons))