Skip to content

Instantly share code, notes, and snippets.

@jaidevd
Created May 9, 2018 07:36
Show Gist options
  • Save jaidevd/b3b67498ba6dec0376193cfb2a6606d3 to your computer and use it in GitHub Desktop.
Save jaidevd/b3b67498ba6dec0376193cfb2a6606d3 to your computer and use it in GitHub Desktop.
inheritance in tests
#! /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