-2

I have this class which gives me output of "I am in level 1" but doesn't out "I am in level 2" so I assume get_full_name(self) part isn't being executed any help?

class UserTest(TestCase):

    user = UserFactory()

    def test_user_login_client(self):
        self.client.login(username=self.user.email, password=self.user.password)
        print "I am in level 1"

    def get_full_name(self):
        print "I am in level 2"
        full_name = user.full_name()

        return full_name
Cœur
  • 37,241
  • 25
  • 195
  • 267
Marksman
  • 59
  • 14
  • This code won't even parse with python, your class definition is empty. – Michael Sondergaard Jan 08 '16 at 20:04
  • please elaborate ? am new to python – Marksman Jan 08 '16 at 20:07
  • Python expects an indented block under your class definition. Without that, the code will not parse. Does the indentation of this example match the code that you are testing? – JCVanHamme Jan 08 '16 at 20:09
  • 1
    Indeed. The indentation of the code you posted cannot match what you are running to receive an output of "I am in level 1". It is unclear what exact output you want, so I cannot be of more help without a clearer problem statement. Indeed, print "I am in level 2" will not be executed since it's inside a function definition, one that is never called. – Michael Sondergaard Jan 08 '16 at 20:11
  • couldn't set the indentation of code while posting the question fixed it now n that's how it looks like in my code copy n yes there is code above this specific section of code in file which deals with all import and stuff my only problem here is i cannot get code below def get_full_name(self): executed n cant figure out why – Marksman Jan 08 '16 at 20:21
  • Well, how do you get the code in `test_user_login_client` to execute? "i am in level 1" is currently inside of that function and won't print without the function being called. If you actually call `get_full_name` it will print your level 2 message. – JCVanHamme Jan 08 '16 at 20:24
  • well i am writing tests for django and using factory boy so calling my test does execution and does return me results of test_user_login_client(self) but its not executing second function and returns the test as successful – Marksman Jan 08 '16 at 20:29

1 Answers1

0

The convention is to prefix the test functions with test_

You need to rename get_full_name to test_get_full_name

John La Rooy
  • 295,403
  • 53
  • 369
  • 502