Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#29352 closed defect (worksforme)

AttributeError when running bandwidth_file.py test

Reported by: juga Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Running pytest test/unit/descriptor/bandwidth_file.py both in Python 2.7 and 3.5

test/unit/descriptor/bandwidth_file.py .....FF..                                                                                           [100%]

==================================================================== FAILURES ====================================================================
______________________________________________________ TestBandwidthFile.test_header_for_v1 ______________________________________________________

self = <test.unit.descriptor.bandwidth_file.TestBandwidthFile testMethod=test_header_for_v1>

    def test_header_for_v1(self):
      """
        Document version 1.0 predates headers, and as such should be prohibited.
        """
    
>     self.assertRaisesWith(ValueError, 'Headers require BandwidthFile version 1.1 or later', BandwidthFile.create, {'new_header': 'neat stuff'})
E     AttributeError: 'TestBandwidthFile' object has no attribute 'assertRaisesWith'

test/unit/descriptor/bandwidth_file.py:181: AttributeError
____________________________________________________ TestBandwidthFile.test_invalid_timestamp ____________________________________________________

self = <test.unit.descriptor.bandwidth_file.TestBandwidthFile testMethod=test_invalid_timestamp>

    def test_invalid_timestamp(self):
      """
        Invalid timestamp values.
        """
    
      test_values = (
        b'',
        b'boo',
        b'123.4',
        b'-123',
      )
    
      for value in test_values:
        expected_exc = "First line should be a unix timestamp, but was '%s'" % value
>       self.assertRaisesWith(ValueError, expected_exc, BandwidthFile.create, {'timestamp': value})
E       AttributeError: 'TestBandwidthFile' object has no attribute 'assertRaisesWith'

test/unit/descriptor/bandwidth_file.py:209: AttributeError
======================================================= 2 failed, 7 passed in 0.11 seconds =======================================================

Child Tickets

Change History (3)

comment:1 Changed 10 months ago by atagar

Resolution: worksforme
Status: newclosed

Hi juga, that's not how you run Stem's tests. Please check...

https://stem.torproject.org/faq.html#how-do-i-run-the-tests

Use the '--test' argument if you would like to run only a single test.

% ./run_tests.py --unit --test descriptor.bandwidth_file
======================================================================
                             INITIALISING                             
======================================================================

  stem version...                            1.7.1-dev (commit f1c6e30d)
  python version...                          2.7.12
  operating system...                        Linux (Ubuntu 16.04)
  cryptography version...                    2.0.3
  pynacl version...                          missing
  mock version...                            2.0.0
  pyflakes version...                        1.5.0
  pycodestyle version...                     2.4.0
  checking for orphaned .pyc files...        done (0.0s)
  checking for unused tests...               done (0.0s)
  importing test modules...                  done (0.0s)

======================================================================
                              UNIT TESTS                              
======================================================================

  descriptor.bandwidth_file...                         success (0.01s)

TESTING PASSED (0 seconds)

comment:2 in reply to:  1 Changed 10 months ago by juga

Replying to atagar:

Hi juga, that's not how you run Stem's tests. Please check...

https://stem.torproject.org/faq.html#how-do-i-run-the-tests

oh, didn't see that, sorry.

Use the '--test' argument if you would like to run only a single test.

% ./run_tests.py --unit --test descriptor.bandwidth_file
[...] 
TESTING PASSED (0 seconds)

I'm still doing something wrong, cause i get:

[...]
  checking for unused tests...               failed

Test modules are missing from our test/settings.cfg:
test.integ.directory.bandwidth_authority.TestAuthority

comment:3 Changed 10 months ago by atagar

Hi juga. That's because you attempted to start to write a Stem integ test but didn't include it in 'test/settings.cfg'. Simply add a line below its 'test.integ_tests' field (which determines the order that tests are ran in) or remove the test you were working on.

Note: See TracTickets for help on using tickets.