目前,我正在http://proctor.andela.com/上进行一些编程测试,我的OOP问题代码在pyCharm和Idle中运行良好,但是在对提供的编辑器中的代码进行“测试”的同时,我仍然得到了这个错误。
/bin/sh: 1: python/nose2 2/bin/nose2 2:未找到
因此我不能提交我的代码。
我尝试了以下几点:
进一步的研究表明,这是由用于计算代码的单元测试带来的,这是否意味着这是一个服务器问题?
由于试验是有时限的,所以我很感激在这个问题上取得进展的任何方法。
编辑/附加信息转移到另一个实验室,但仍然得到相同的错误。这不是指环境配置错误还是服务器端错误吗?
我目前的设置是:
Linux 17.3 64位按照建议,通过谷歌Chrome进行测试。当我使用Firefox时也会出现同样的错误。
我的代码,供参考:
class BankAccount(object):
def deposit(self):
pass
def withdraw(self):
pass
class SavingsAccount(BankAccount):
def __init__(self):
self.balance = 500
def deposit(self, amount):
if amount < 0:
return 'Invalid deposit amount'
else:
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
return 'Invalid withdraw amount'
elif amount > self.balance:
return 'Cannot withdraw beyond the current account balance'
elif (self.balance - amount < 500):
return 'Cannot withdraw beyond the minimum account balance'
else:
self.balance -= amount
return self.balance
class CurrentAccount(BankAccount):
def __init__(self):
self.balance = 0
def deposit(self, amount):
if amount < 0:
return 'Invalid deposit amount'
else:
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
return 'Invalid withdrawal amount'
elif amount > self.balance:
return 'Cannot withdraw beyond the current account balance'
else:
self.balance -= amount
return self.balance最终编辑&关闭(由Andela确认),测试平台确实存在严重问题,导致其脱机进行维护。因此,我可以通过确认这是一个服务器端问题来结束这个问题。谢谢所有答复/评论的人。
发布于 2017-03-20 02:51:39
所有的测试都是返回错误/bin/sh: 1: python/nose2/bin/nose2: not found.,我想这与那些家伙有关。我想所有代码都不可能有相同的错误
发布于 2017-03-19 10:44:15
好的:看看test.spy代码,仔细看它,因为它与解决方案有很大关系。我发现了这个错误:
HERE IS AN ERROR/BUG IN YOUR CODE
Results:
{"finished": true, "success": [{"fullName":
"test_current_account_can_withdraw_valid_cash_amounts", "passedSpecNumber": 1}, {"fullName": "test_current_account_is_instance_of_bank_account", "passedSpecNumber": 2}, {"fullName": "test_savings_account_can_withdraw_valid_amounts_successfully", "passedSpecNumber": 3},
{"fullName": "test_savings_account_is_instance_of_bank_account", "passedSpecNumber": 4}], "passed": false, "started": true, "failures": [{"failedSpecNumber": 1, "fullName": "test_current_account_can_deposit_valid_amounts", "failedExpectations": [{"message": "Failure in line 20, in test_current_account_can_deposit_valid_amounts\n self.assertEquals(balance, 1500)\nAssertionError: None != 1500\n"}]}, {"failedSpecNumber": 2, "fullName": "test_current_account_cannot_withdraw_more_than_current_balance", "failedExpectations": [{"message": "Failure in line 24, in test_current_account_cannot_withdraw_more_than_current_balance\n self.assertEquals(message, 'Cannot withdraw beyond the current account balance', msg='No overdrafts')\nAssertionError: No overdrafts\n"}]},
{"failedSpecNumber": 3, "fullName": "test_savings_account_can_deposit_valid_amounts", "failedExpectations": [{"message": "Failure in line 44, in test_savings_account_can_deposit_valid_amounts\n
self.assertEquals(balance, (1500 + init_balance)
, msg='Balance does not match deposit')\nAssertionError: Balance does not match deposit\n"}]}, {"failedSpecNumber": 4, "fullName": "test_savings_account_cannot_withdraw_more_than_current_balance", "failedExpectations": [{"message": "Failure in line 48, in test_savings_account_cannot_withdraw_more_than_current_balance\n self.assertEquals(message, 'Cannot withdraw beyond the current account balance', msg='No overdrafts')\nAssertionError: No overdrafts\n"}]}], "specs": {"count": 8, "pendingCount": 0, "time": "0.016354"}}这个人应该告诉你,你有某些事情要证明/测试。
发布于 2017-03-19 15:07:09
没有隐藏的测试。单元测试应该导入类,但它没有。尝试复制测试并放置导入类,然后运行unittest,您的代码很可能会在另一个环境中返回ok。这是令人沮丧的不公平。
https://stackoverflow.com/questions/42873477
复制相似问题