Coder Social home page Coder Social logo

Comments (2)

repcsi avatar repcsi commented on July 18, 2024

I think you can, if there was an issue both solutions would probably point it out. I also added a test that reverse('home') points to / as from my earlier experience this worth checking:

def test_checkif_home_is_slash(self):  
        response_slash = self.client.get('/')  
        self.assertEqual(self.response.content, response_slash.content)

But basically "test_homepage_url_resolves_homepageview" does the same with more steps under the hood.

I'm also curious what @wsvincent thinks about this as he is more experienced.

from djangoforprofessionals.

wsvincent avatar wsvincent commented on July 18, 2024

Hi @repcsi and @shutteritch, I'm horribly late in response but finishing up the 4.0 update and wanted to weigh in here.

Testing is ultimately subjective. As long as something fails once it will trigger an error so I think there's nothing wrong with also adding a test for / if the home URL changes.

In the book we add tests right after doing code and I largely just give the tests and they pass. In reality, I was breaking things as I added new features and added tests along the way so it is unusual to have perfect tests all the time and it is normal and advised to add as many little things as you can think of. You can always have more tests.

Hope that helps! Thank you both for commenting and reading the book :)

from djangoforprofessionals.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.