Google, tuvaletlerde napıyor?

OBA
21-03-2007, 19:41   |  #1  
OP Yıllanmış Üye
Teşekkür Sayısı: 0
3,757 mesaj
Kayıt Tarihi:Kayıt: Kas 2005

Bukadar çılgın bir şirketin tuvaletlerini merak ettinizmi hiç? Herzamanki dehasınısı burda da işletiyor. Tabi akla ilk önce masaj yapan veya sizden aldığı örnekleri analiz eden bir tuvalet gelebilir ama bunlar değil. "Testing on the Toilet, Testing code that uses databases."  gibi başlıkları olan testler çıkıyor. Teknik konularla ilgili kısa makaleler ve kodlar var. Nasıl mı? işte size örnek

TotT: Better Stubbing in Python
So you've learned all about method stubs, mock objects, and fakes. You might be tempted to stub out slow or I/O-dependent built-ins. For example:

def Foo(path):
   if os.path.exists(path):
     return DoSomething()
   else:
     return DoSomethingElse()

def testFoo(self):         # Somewhere in your unit test class
   old_exists = os.path.exists
   try:
     os.path.exists = lambda x: True
     self.assertEqual(Foo('bar'), something)
     os.path.exists = lambda x: False
     self.assertEqual(Foo('bar'), something_else)
   finally:
     # Remember to clean-up after yourself!
     os.path.exists = old_exists


Congratulations, you just achieved 100% coverage! Unfortunately, you might find that this test fails in strange ways. For example, given the following DoSomethingElse which checks the existence of a different file:

def DoSomethingElse():
   assert os.path.exists(some_other_file)
   return some_other_file


Foo will now throw an exception in its second invocation because os.path.exists returns False so the assertion fails.


You could avoid this problem by stubbing or mocking out DoSomethingElse, but the task might be daunting in a real-life situation. Instead, it is safer and faster to parameterize the built-in:

def Foo(path, path_checker=os.path.exists):
   if path_checker(path):
     return DoSomething()
   else:
     return DoSomethingElse()

def testFoo(self):
   self.assertEqual(Foo('bar', lambda x: True), something)
   self.assertEqual(Foo('bar', lambda x: False), something_else)

ufuks
22-03-2007, 22:54   |  #2  
Yıllanmış Üye
Teşekkür Sayısı: 6
3,430 mesaj
Kayıt Tarihi:Kayıt: Mar 2006

Ne bu ya.Bakalım da herkes ingilizce biliyor mu.Şahsen ben bişey anlamadım.

Son Düzenleme: ufuks ~ 22 Mart 2007 22:57
theironman
23-03-2007, 01:09   |  #3  
theironman avatarı
Genel Denetmen
Teşekkür Sayısı: 63
8,347 mesaj
Kayıt Tarihi:Kayıt: Oca 2004

Ufuk haklı. Bilgi paylaşırken dil olayını düşünürsen iyi olur, herkes ingilizce bilmiyor sonuçta.

OBA
23-03-2007, 12:14   |  #4  
OP Yıllanmış Üye
Teşekkür Sayısı: 0
3,757 mesaj
Kayıt Tarihi:Kayıt: Kas 2005

Türkçeye gerek yok ki. Zaten yukarda da dediğim gibi teknik konular. Programcılıkla uğraşanların anlıyacağı birşey

egemengiga
23-03-2007, 13:57   |  #5  
Yıllanmış Üye
Teşekkür Sayısı: 0
4,298 mesaj
Kayıt Tarihi:Kayıt: Oca 2004

o zaman konudisi yerine programlama bolumunu tercih etmeliydin. sonucta ingilizce gibi programlama dilleri de adi uzerinde bir DİL. konu disinda bunu okuyanlarn %90 i bundan bir sey anlamaz. cunku programlama ile ugrasanlarin genelde bu bolume ayiracak zamanlari yoktur. daha cok sorun cozme ile ugrasirlar ve isleri duserse forumlardan arastirma yaparlar. bunlari niye yazdim anlamadim zaten sen de biliyorsunGöz kırpma

ufuks
23-03-2007, 15:29   |  #6  
Yıllanmış Üye
Teşekkür Sayısı: 6
3,430 mesaj
Kayıt Tarihi:Kayıt: Mar 2006
OBA
Türkçeye gerek yok ki. Zaten yukarda da dediğim gibi teknik konular. Programcılıkla uğraşanların anlıyacağı birş
Kardeşim bak progralama bölümü var forumda görmüş olmalısın.Oraya yaz da millet dam ustunde saksağan demesin.Neyse boylece senn programlama dili bildigini millet görmüş oldu.Sevinmelisin.Göz kırpma

OBA
23-03-2007, 17:54   |  #7  
OP Yıllanmış Üye
Teşekkür Sayısı: 0
3,757 mesaj
Kayıt Tarihi:Kayıt: Kas 2005

Programcılık bölümünden haberim var ve eğer oraya bakarsanız bir çok mesajımı zaten görürsünüz. Niye oraya yazmadığıma gelince. Sonuçta bu bir soru falan değil, haber. Birçok kullanıcını ilgisini çekebilcek bir haber. Bunu programcığa yazsam hangi başlığa yazıcam? vb, c? Sonuçta bu bir haber doğradan programcılıkla ilgisi yok. Bu gaztede haber okumak gibi. Bir matematik habererinden bahsedilir. İlk önce genel okuyucunun anlıyacağı ve birazda varsa magazin yönünden bahsedilir. Birde haberin olduğu yerde daha detayını isteyenler için konuya daha bilimsel yaklaşarak küçükte olsa yazılan bölüm olur. Okuyucuda istedeği ve anladığı kadarını okur.

omer_6134
07-06-2007, 20:29   |  #8  
Yıllanmış Üye
Teşekkür Sayısı: 6
2,789 mesaj
Kayıt Tarihi:Kayıt: Nis 2007

Vay be google bak her şeyi rakamlar oldu adını sorsan 58gd1df978fh248sf gibi şeyler diyecek

:):):)