class_docstr: Test StringConverter
class_docstr_tok: ["Test","StringConverter"]
docstr: Tests the upgrade method.
docstr_tok: ["Tests","the","upgrade","method","."]
code: def test_upgrade(self):
      "Tests the upgrade method."
  
      converter = StringConverter()
      assert_equal(converter._status, 0)
  
      # test int
      assert_equal(converter.upgrade("0"), 0)
      assert_equal(converter._status, 1)
  
      # On systems where long defaults to 32-bit, the statuses will be
      # offset by one, so we check for this here.
      import numpy.core.numeric as nx
  
      status_offset = int(
          nx.dtype(nx.int_).itemsize < nx.dtype(nx.int64).itemsize
      )
  
      # test int > 2**32
      assert_equal(converter.upgrade("17179869184"), 17179869184)
      assert_equal(converter._status, 1 + status_offset)
  
      # test float
      assert_allclose(converter.upgrade("0."), 0.0)
      assert_equal(converter._status, 2 + status_offset)
  
      # test complex
      assert_equal(converter.upgrade("0j"), complex("0j"))
      assert_equal(converter._status, 3 + status_offset)
  
      # test str
      # note that the longdouble type has been skipped, so the
      # _status increases by 2. Everything should succeed with
      # unicode conversion (8).
      for s in ["a", b"a"]:
          res = converter.upgrade(s)
          assert_(type(res) is str)
          assert_equal(res, "a")
          assert_equal(converter._status, 8 + status_offset)
  
imports: import time
  from datetime import date
  import numpy
  from numpy.testing import assert_, assert_equal, assert_allclose, assert_raises
  from numpy.lib._iotools import LineSplitter, NameValidator, StringConverter, has_nested_fields, easy_dtype, flatten_dtype
label_desc: Use image node_id 2 for calling the TestStringConverter obj's underlying member method code with example usage: obj.test_upgrade() without return types