This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' from _10gen import jsMap, jsArray assert jsMap.a == 1 assert jsMap.b == 4 assert dir(jsMap) == ['a', 'b'] assert jsMap.keys() == dir(jsMap) assert len(jsMap.keys()) == 2 def extract(a=None, b=None): assert a == 1 assert b == 4 extract(**jsMap) def extractAry(a, b, c): assert a == 4 assert b == 8 assert c == 2 extractAry(*jsArray)
''' import _10gen from _10gen import jsMap assert jsMap.has_key('a') assert jsMap.has_key('b') assert jsMap.has_key('n') assert not jsMap.has_key('c') assert 'a' in jsMap assert 'b' in jsMap assert 'n' in jsMap assert 'c' not in jsMap d = jsMap.copy() _10gen.assert.eq(len(jsMap.keys()), len(d.keys())) _10gen.assert.eq(len(jsMap), len(d)) _10gen.assert.eq(d['a'], jsMap.a) _10gen.assert.eq(d['a'], jsMap['a']) _10gen.assert.eq(d['n'], jsMap.n) _10gen.assert.eq(d['n'], jsMap['n']) def compare_list_methods_by_sorted(d, j, meth): d_result = list(getattr(d, meth)()) j_result = list(getattr(j, meth)()) d_result.sort() j_result.sort() _10gen.assert.eq(d_result, j_result) compare_list_methods_by_sorted(d, jsMap, 'iteritems')