Created
May 9, 2018 07:36
-
-
Save jaidevd/b3b67498ba6dec0376193cfb2a6606d3 to your computer and use it in GitHub Desktop.
inheritance in tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# vim:fenc=utf-8 | |
# | |
# JSM product code | |
# | |
# (C) Copyright 2018 Juxt SmartMandate Pvt Ltd | |
# All right reserved. | |
# | |
# This file is confidential and NOT open source. Do not distribute. | |
# | |
""" | |
""" | |
from unittest import TestCase, main | |
class TestBase(TestCase): | |
@classmethod | |
def setUpClass(cls): | |
cls.some_attr = 'hello' | |
def test_for_child(self): | |
if not hasattr(self, 'CONST'): | |
self.skipTest('Only for child.') | |
self.assertTrue(isinstance(self.CONST, int)) | |
def test_for_parent_and_child(self): | |
self.assertTrue(True) | |
class MyClass(TestBase): | |
@classmethod | |
def setUpClass(cls): | |
super().setUpClass() | |
cls.CONST = 123 | |
def test_exclusive_to_child(self): | |
self.assertTrue(True) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment