Path: csiph.com!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Date: Sun, 20 Dec 2015 00:41:12 +0000 Lines: 40 Message-ID: References: <5ec1d759-a2ab-4193-a4aa-869c0bf0506c@googlegroups.com> <8b40be10-d859-418d-b6b6-f687463a4847@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de N0N86q77/xhV1XWww8jqFwYtvK8wLZZtHAUWjcGraJ3Q== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.03; 'true,': 0.04; 'from:addr:yahoo.co.uk': 0.05; 'false,': 0.07; 'subject:help': 0.07; 'expected.': 0.09; 'question?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'advance': 0.10; 'python': 0.10; 'output': 0.13; 'def': 0.13; 'subject: \n ': 0.15; '"invalid': 0.16; '"test': 0.16; '23,': 0.16; 'code?': 0.16; 'outputs': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:class': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.16; 'beginner': 0.18; 'subject:project': 0.18; 'language': 0.19; 'lawrence': 0.22; 'code,': 0.23; 'wrote': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.26; 'skip:" 20': 0.26; 'skip:m 30': 0.27; 'error': 0.27; 'question': 0.27; 'executing': 0.27; 'correct': 0.28; "i'm": 0.30; 'transaction': 0.30; 'code': 0.30; 'skip:[ 10': 0.31; 'skip:_ 10': 0.32; 'language.': 0.32; 'run': 0.33; 'class': 0.33; 'running': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'requirement': 0.37; 'things': 0.38; 'skip:s 40': 0.38; 'wrong': 0.38; 'means': 0.39; 'test': 0.39; 'whatever': 0.39; 'does': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'mark': 0.40; 'subject:with': 0.40; 'still': 0.40; 'your': 0.60; 'subject:Need': 0.61; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'our': 0.64; 'presumably': 0.84; 'pythonistas,': 0.84; 'absolutely': 0.88 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 195.147.228.69 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <8b40be10-d859-418d-b6b6-f687463a4847@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100616 On 19/12/2015 23:19, malitician@gmail.com wrote: > you are absolutely correct Mark > i'm a beginner in python and from the original question and test case given above i wrote this > > class BankAccount(object): > def __init__(self, initial_balance=0): > self.balance = initial_balance > def deposit(self, amount): > self.balance +=amount > def withdraw(self, amount): > self.balance -= amount > my_account = BankAccount(90) > my_account.withdraw(1000) > if my_account.balance < 4: > print('invalid transaction') > class MinimumBalanceAccount(BankAccount): > def __init__(self, MinimumBalance=4): > self.minbalance = MinimumBalance > > after executing this i got this TEST SOLUTION ERROR which i don't know what it means > > {"finished": true, "success": [{"fullName": "test_balance", "passedSpecNumber": 1}, {"fullName": "test_deposit", "passedSpecNumber": 2}, {"fullName": "test_sub_class", "passedSpecNumber": 3}, {"fullName": "test_withdraw", "passedSpecNumber": 4}], "passed": false, "started": true, "failures": [{"failedSpecNumber": 1, "fullName": "test_invalid_operation", "failedExpectations": [{"message": "Failure in line 23, in test_invalid_operation\n self.assertEqual(self.my_account.withdraw(1000), \"invalid transaction\", msg='Invalid transaction')\nAssertionError: Invalid transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time": "0.000065"}} > -910 > invalid transaction > > SO please what is wrong with my code, does it not meet the requirement of the "test case" given above in the question? > Thanks in advance > It's a start but you've still left things out. If I run your code as given above it outputs "invalid transaction", exactly as expected. So how are you running the code? Where does the extra output you give above come from, presumably the "test case", whatever that might be? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence