Skip to content

Commit

Permalink
add tests for @sentinel_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Oct 21, 2019
1 parent f74bd12 commit dec7f0c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/python/pants_test/util/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from abc import ABC, abstractmethod
from dataclasses import FrozenInstanceError, dataclass

from pants.util.meta import SingletonMetaclass, classproperty, frozen_after_init, staticproperty
from pants.util.meta import (SingletonMetaclass, classproperty, frozen_after_init,
sentinel_attribute, staticproperty)
from pants_test.test_base import TestBase


Expand Down Expand Up @@ -246,6 +247,22 @@ def f(cls):
self.assertEqual(Concrete2.f, 'hello')


class SentinelAttributeTest(unittest.TestCase):

def test_sentinel_attribute(self):
@sentinel_attribute('_test_attr_name')
def f(cls):
return f.define_instance_of(cls)

@f
class C:
pass

self.assertEqual(f.sentinel_attribute, '_test_attr_name')
self.assertTrue(C._test_attr_name)
self.assertTrue(f.is_instance(C))


class FrozenAfterInitTest(unittest.TestCase):

def test_no_init(self) -> None:
Expand Down

0 comments on commit dec7f0c

Please sign in to comment.