def test_split_options(self):
        self.assertRaises(ConfigurationError, split_options, 'foo')
        self.assertRaises(ConfigurationError, split_options, 'foo=bar;foo')
        self.assertTrue(split_options('ssl=true'))
        self.assertTrue(split_options('connect=true'))
        self.assertTrue(split_options('ssl_match_hostname=true'))

        # Test Invalid URI options that should throw warnings.
        with warnings.catch_warnings():
            warnings.filterwarnings('error')
            self.assertRaises(Warning, split_options,
                              'foo=bar', warn=True)
            self.assertRaises(Warning, split_options,
                              'socketTimeoutMS=foo', warn=True)
            self.assertRaises(Warning, split_options,
                              'socketTimeoutMS=0.0', warn=True)
            self.assertRaises(Warning, split_options,
                              'connectTimeoutMS=foo', warn=True)
            self.assertRaises(Warning, split_options,
                              'connectTimeoutMS=0.0', warn=True)
            self.assertRaises(Warning, split_options,
                              'connectTimeoutMS=1e100000', warn=True)
            self.assertRaises(Warning, split_options,
                              'connectTimeoutMS=-1e100000', warn=True)
            self.assertRaises(Warning, split_options,
                              'ssl=foo', warn=True)
            self.assertRaises(Warning, split_options,
                              'connect=foo', warn=True)
            self.assertRaises(Warning, split_options,
                              'ssl_match_hostname=foo', warn=True)

            # On most platforms float('inf') and float('-inf') represent
            # +/- infinity, although on Python 2.4 and 2.5 on Windows those
            # expressions are invalid
            if not (sys.platform == "win32" and (2, 5) <= sys.version_info):
                self.assertRaises(Warning, split_options,
                                  'connectTimeoutMS=inf', warn=True)
                self.assertRaises(Warning, split_options,
                                  'connectTimeoutMS=-inf', warn=True)

            self.assertRaises(Warning, split_options, 'wtimeoutms=foo',
                              warn=True)
            self.assertRaises(Warning, split_options, 'wtimeoutms=5.5',
                              warn=True)
            self.assertRaises(Warning, split_options, 'fsync=foo',
                              warn=True)
            self.assertRaises(Warning, split_options, 'fsync=5.5',
                              warn=True)
            self.assertRaises(Warning,
                              split_options, 'authMechanism=foo',
                              warn=True)

        # Test invalid options with warn=False.
        self.assertRaises(ConfigurationError, split_options, 'foo=bar')
        self.assertRaises(ValueError, split_options, 'socketTimeoutMS=foo')
        self.assertRaises(ValueError, split_options, 'socketTimeoutMS=0.0')
        self.assertRaises(ValueError, split_options, 'connectTimeoutMS=foo')
        self.assertRaises(ValueError, split_options, 'connectTimeoutMS=0.0')
        self.assertRaises(ValueError, split_options,
                          'connectTimeoutMS=1e100000')
        self.assertRaises(ValueError, split_options,
                          'connectTimeoutMS=-1e100000')
        self.assertRaises(ValueError, split_options, 'ssl=foo')
        self.assertRaises(ValueError, split_options, 'connect=foo')
        self.assertRaises(ValueError, split_options, 'ssl_match_hostname=foo')
        if not (sys.platform == "win32" and sys.version_info <= (2, 5)):
            self.assertRaises(ValueError, split_options,
                              'connectTimeoutMS=inf')
            self.assertRaises(ValueError, split_options,
                              'connectTimeoutMS=-inf')
        self.assertRaises(ValueError, split_options, 'wtimeoutms=foo')
        self.assertRaises(ValueError, split_options, 'wtimeoutms=5.5')
        self.assertRaises(ValueError, split_options, 'fsync=foo')
        self.assertRaises(ValueError, split_options, 'fsync=5.5')
        self.assertRaises(ValueError,
                          split_options, 'authMechanism=foo')

        # Test splitting options works when valid.
        self.assertTrue(split_options('socketTimeoutMS=300'))
        self.assertTrue(split_options('connectTimeoutMS=300'))
        self.assertEqual({'sockettimeoutms': 0.3},
                         split_options('socketTimeoutMS=300'))
        self.assertEqual({'sockettimeoutms': 0.0001},
                         split_options('socketTimeoutMS=0.1'))
        self.assertEqual({'connecttimeoutms': 0.3},
                         split_options('connectTimeoutMS=300'))
        self.assertEqual({'connecttimeoutms': 0.0001},
                         split_options('connectTimeoutMS=0.1'))
        self.assertTrue(split_options('connectTimeoutMS=300'))
        self.assertTrue(isinstance(split_options('w=5')['w'], int))
        self.assertTrue(isinstance(split_options('w=5.5')['w'], string_type))
        self.assertTrue(split_options('w=foo'))
        self.assertTrue(split_options('w=majority'))
        self.assertTrue(split_options('wtimeoutms=500'))
        self.assertEqual({'fsync': True}, split_options('fsync=true'))
        self.assertEqual({'fsync': False}, split_options('fsync=false'))
        self.assertEqual({'authmechanism': 'GSSAPI'},
                         split_options('authMechanism=GSSAPI'))
        self.assertEqual({'authmechanism': 'MONGODB-CR'},
                         split_options('authMechanism=MONGODB-CR'))
        self.assertEqual({'authmechanism': 'SCRAM-SHA-1'},
                         split_options('authMechanism=SCRAM-SHA-1'))
        self.assertEqual({'authsource': 'foobar'},
                         split_options('authSource=foobar'))
        self.assertEqual({'maxpoolsize': 50}, split_options('maxpoolsize=50'))
dataset/ETHPy150Open mongodb/mongo-python-driver/test/test_uri_parser.py/TestURI.test_split_options/swapped operands of `<=`