Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 567813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:07:24+00:00 2026-05-13T13:07:24+00:00

I have a test case: class LoginTestCase(unittest.TestCase): … I’d like to use it in

  • 0

I have a test case:

class LoginTestCase(unittest.TestCase):
    ...

I’d like to use it in a different test case:

class EditProfileTestCase(unittest.TestCase):
  def __init__(self):
    self.t = LoginTestCase()
    self.t.login()

This raises:

ValueError: no such test method in <class 'LoginTest: runTest`

I looked at the unittest code where the exception is being called, and it looks like the tests aren’t supposed to be written this way. Is there a standard way to write something you’d like tested so that it can be reused by later tests? Or is there a workaround?

I’ve added an empty runTest method to LoginTest as a dubious workaround for now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:07:24+00:00Added an answer on May 13, 2026 at 1:07 pm

    unittest does deep black magic — if you choose to use it to run your unit-tests (I do, since this way I can use a very powerful battery of test runners &c integrated into the build system at my workplace, but there are definitely worthwhile alternatives), you’d better play by its rules.

    In this case, I’d simply have EditProfileTestCase derive from LoginTestCase (rather than directly from unittest.TestCase). If there are some parts of LoginTestCase that you do want to also test in the different environment of EditProfileTestCase, and others that you don’t, it’s a simple matter to refactor LoginTestCase into those two parts (possibly using multiple inheritance) and if some things need to happen slightly differently in the two cases, factor them out into auxiliary “hook methods” (in a “Template Method” design pattern) — I use all of these approaches often to diminish boilerplate and increase reuse in the copious unit tests I always write (if I have unit-test coverage < 95%, I always feel truly uneasy — below 90%, I start to feel physically sick;-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test case class like this one: import unittest import sys class
Imagine I have a test like this: class MyUnitTest < Test::Unit::TestCase def test_first #
I have a collection testcase like this, Test Builds have many Test Case Logs
I have a jUnit4 test case class ( extends TestCase). I am testing some
I have a test case that looks like so: public class MyTest { private
I have the following test case: @ContextConfiguration(/spring/test-context.xml) @TransactionConfiguration(transactionManager=txManager) @Transactional() public class MyEntityDaoTestCase extends AbstractJUnit4SpringContextTests
I have the following code require 'test_helper' class ApplicationControllerTest < ActionController::TestCase test should display
I have this test case def setUp(self): self.user = User.objects.create(username=tauri, password='gaul') def test_loginin_student_control_panel(self): c
I have the following code with the corresponding test case: class XXX attr_accessor :source
I have the Unit Test Class named CarouselWithXmlTests.I have single test case.If i entered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.