jeremiah-c-leary / vhdl-style-guide

Style guide enforcement for VHDL
GNU General Public License v3.0
179 stars 38 forks source link

Unittest `test_rule_id` in test_rule.py uses non-existent `rule.Rule` class attribute `id` #1089

Closed JHertz5 closed 6 months ago

JHertz5 commented 6 months ago

Environment

$ ./bin/vsg -v
VHDL Style Guide (VSG) version: 3.20.0
Git commit SHA: 22beaa35

Describe the bug This is a very minor problem, but: In the unit tests for the rule.Rule class, there is a test called test_rule_id:


    def test_rule_id(self):
        oRule = rule.Rule()
        self.assertFalse(oRule.identifier)
        oRule.id = 'rule id 001'
        self.assertEqual(oRule.id, 'rule id 001')

This tests the attribute identifier. However, note that the last two lines set a new attribute id that is used nowhere else in the codebae, and tests the value of that attribute instead of indentifier. This is an easy mistake to make and IMO it's a weakness of the language that is doesn't raise some kind of warning when this happens.

To Reproduce Steps to reproduce the behavior:

  1. Go to vsg/tests/rule/test_rule.py, line 39.
  2. Observe that the id is not an attribute of the rule.Rule class.

Expected behavior This test should test the identifier attribute.

jeremiah-c-leary commented 6 months ago

Morning @JHertz5 ,

I must have changed my mind somewhere along the way and the way the test is written it didn't matter what called the attribute.

I do not believe I ever would have this, so thanks for finding it.

--Jeremy